Skip to content

[Code Quality] refactor: narrow safe_output_handlers.go and actions.go 'any' fields to concrete types #48892

Description

@github-actions

Description

Two clear-cut any narrowing opportunities were flagged in a Go type-consistency scan:

  1. 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.
  2. 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 ·

  • expires on Jul 30, 2026, 5:24 AM UTC-08:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions