Problem
In validateMCPRequirements (pkg/workflow/mcp_property_validation.go:43-49), a type assertion is performed twice on the same value:
// Line 45: asserts and discards the result
if _, ok := mcpType.(string); !ok {
return fmt.Errorf(...)
}
// Line 48: asserts again to extract the value
typeStr = mcpType.(string)
The second assertion on line 48 is safe (it cannot panic because the guard on line 45 returns early if the type is wrong), but it is non-idiomatic Go and wastes one type assertion. The canonical pattern extracts the value in a single assertion.
Location
pkg/workflow/mcp_property_validation.go:43-49
Impact
- Severity: Low
- Affected code:
validateMCPRequirements function
- Risk: No runtime risk (it cannot panic), but the pattern is non-idiomatic and adds unnecessary complexity. It may also confuse readers since the first assertion looks like it validates but discards a valid value.
Recommendation
Combine the check and extraction into one assertion:
Before:
if hasType {
if _, ok := mcpType.(string); !ok {
return fmt.Errorf("tool '%s' mcp configuration 'type' must be a string, got %T...", toolName, mcpType, ...)
}
typeStr = mcpType.(string)
After:
if hasType {
var ok bool
typeStr, ok = mcpType.(string)
if !ok {
return fmt.Errorf("tool '%s' mcp configuration 'type' must be a string, got %T...", toolName, mcpType, ...)
}
Note: A similar (but intentional) pattern exists on line 29 in validateStringProperty where the value is intentionally discarded after the type check — that case is correct as-is.
Validation
Estimated Effort: Trivial
Generated by Sergo (Run 3, 2026-05-08) — Run ID: §25537174291
Generated by Sergo - Serena Go Expert · ● 506.4K · ◷
Problem
In
validateMCPRequirements(pkg/workflow/mcp_property_validation.go:43-49), a type assertion is performed twice on the same value:The second assertion on line 48 is safe (it cannot panic because the guard on line 45 returns early if the type is wrong), but it is non-idiomatic Go and wastes one type assertion. The canonical pattern extracts the value in a single assertion.
Location
pkg/workflow/mcp_property_validation.go:43-49Impact
validateMCPRequirementsfunctionRecommendation
Combine the check and extraction into one assertion:
Before:
After:
Note: A similar (but intentional) pattern exists on line 29 in
validateStringPropertywhere the value is intentionally discarded after the type check — that case is correct as-is.Validation
mcp_property_validationtestsEstimated Effort: Trivial
Generated by Sergo (Run 3, 2026-05-08) — Run ID: §25537174291