Skip to content

[Code Quality] refactor: introduce shared FlexibleID type for JSON-RPC/log id fields duplicated across pkg/cli #48890

Description

@github-actions

Description

Four independent locations in pkg/cli reinvent the same "JSON id may be a string or a number" pattern using bare any fields, each requiring its own ad hoc type-switch/normalization logic:

  • pkg/cli/gateway_logs_types.go:148,159 -- rpcRequestPayload.ID any, rpcResponsePayload.ID any (JSON-RPC 2.0 id)
  • pkg/cli/mcp_tools_privileged.go:299-300 -- logsArgs.RunID any, RunIDOrURL any
  • pkg/cli/logs_models.go:323-324 -- WorkflowRunInfo.RunID any, RunNumber any

Each field's ambiguity is individually justified (JSON-RPC spec, GitHub API id formats), but the pattern is duplicated four times with no shared normalization helper.

Suggested Changes

  • Introduce a single shared type, e.g. type FlexibleID any (or a small wrapper struct) plus one String() normalizer function in a shared location (e.g. pkg/types).
  • Replace the four independent ad hoc implementations with the shared type/helper.

Files Affected

  • pkg/cli/gateway_logs_types.go (lines 148, 159)
  • pkg/cli/mcp_tools_privileged.go (lines 299-300)
  • pkg/cli/logs_models.go (lines 323-324)

Success Criteria

  • A single shared FlexibleID-style type/helper exists and is used by all four call sites
  • Existing type-switch/normalization logic replaced by the shared helper
  • All existing tests pass

Source

Extracted from Typist - Go Type Consistency Analysis #48872

Priority

Low - 1-2 hours effort, reduces duplicated normalization logic

🔍 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions