Description
Two clear-cut any narrowing opportunities were flagged in a Go type-consistency scan:
pkg/workflow/safe_output_handlers.go:17 -- safeOutputHandlerDescriptor.NewConfig func() any is instantiated ~40 times as func() any { return &XConfig{} }, each closure always returning exactly one concrete pointer type. A generic Descriptor[T any]{ NewConfig func() *T } would give compile-time guarantees instead of relying on runtime type assertions that currently only surface a mismatch as a panic.
pkg/cli/actions.go:15 -- convertToGitHubActionsEnv(env any, envVarMetadata []EnvironmentVariable) map[string]string. All 3 call sites (pkg/cli/mcp_add.go:200,222,271) always pass a map[string]any pulled from server.Config["env"].
Suggested Changes
- (Optional/larger, may be split into its own follow-up) Make the safe-output handler descriptor generic:
Descriptor[T any]{ NewConfig func() *T }.
- Change
convertToGitHubActionsEnv signature to func convertToGitHubActionsEnv(env map[string]any, envVarMetadata []EnvironmentVariable) map[string]string, removing the internal env.(map[string]any) type-assertion branch.
Files Affected
pkg/workflow/safe_output_handlers.go:17
pkg/cli/actions.go:15
pkg/cli/mcp_add.go:200,222,271
Success Criteria
convertToGitHubActionsEnv takes a concrete map[string]any parameter; dead type-assertion branch removed
- All existing tests pass
Source
Extracted from Typist - Go Type Consistency Analysis #48872
Priority
Low-Medium - the actions.go fix is <1 hour; the generics descriptor is a larger follow-up if scope allows
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · aut00 · 51.4 AIC · ⌖ 5.2 AIC · ⊞ 9.9K · ◷
Description
Two clear-cut
anynarrowing opportunities were flagged in a Go type-consistency scan:pkg/workflow/safe_output_handlers.go:17--safeOutputHandlerDescriptor.NewConfig func() anyis instantiated ~40 times asfunc() any { return &XConfig{} }, each closure always returning exactly one concrete pointer type. A genericDescriptor[T any]{ NewConfig func() *T }would give compile-time guarantees instead of relying on runtime type assertions that currently only surface a mismatch as a panic.pkg/cli/actions.go:15--convertToGitHubActionsEnv(env any, envVarMetadata []EnvironmentVariable) map[string]string. All 3 call sites (pkg/cli/mcp_add.go:200,222,271) always pass amap[string]anypulled fromserver.Config["env"].Suggested Changes
Descriptor[T any]{ NewConfig func() *T }.convertToGitHubActionsEnvsignature tofunc convertToGitHubActionsEnv(env map[string]any, envVarMetadata []EnvironmentVariable) map[string]string, removing the internalenv.(map[string]any)type-assertion branch.Files Affected
pkg/workflow/safe_output_handlers.go:17pkg/cli/actions.go:15pkg/cli/mcp_add.go:200,222,271Success Criteria
convertToGitHubActionsEnvtakes a concretemap[string]anyparameter; dead type-assertion branch removedSource
Extracted from Typist - Go Type Consistency Analysis #48872
Priority
Low-Medium - the actions.go fix is <1 hour; the generics descriptor is a larger follow-up if scope allows