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 · ◷
Description
Four independent locations in
pkg/clireinvent the same "JSON id may be a string or a number" pattern using bareanyfields, 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 anypkg/cli/logs_models.go:323-324--WorkflowRunInfo.RunID any,RunNumber anyEach 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
type FlexibleID any(or a small wrapper struct) plus oneString()normalizer function in a shared location (e.g.pkg/types).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
FlexibleID-style type/helper exists and is used by all four call sitesSource
Extracted from Typist - Go Type Consistency Analysis #48872
Priority
Low - 1-2 hours effort, reduces duplicated normalization logic