Repository navigation
Description
Summary
The new execcommandwithoutcontext analyzer (24th custom linter) landed fully documented (doc.go "All 24", README, and spec_test.go documentedAnalyzers() all at 24 entries) but is not yet CI-enforced. A repo-wide audit shows it is close to enforceable: of ~90 prod exec.Command sites across 30 files, only 3 sit inside context-receiving functions — 2 genuine violations plus 1 false positive (tracked separately as the nil-guard precision issue, #38281). This issue covers converting the 2 genuine sites and the remaining prerequisites for enforcement.
Genuine violations (safe to convert)
Both are in connectStdioMCPServer(ctx context.Context, ...), which is always called with a real, non-nil context (context.WithTimeout(context.Background(), 30*time.Second) in connectToMCPServer), so propagating ctx is correct and binds the MCP subprocess lifetime to the 30s timeout:
// pkg/cli/mcp_inspect_mcp.go
func connectStdioMCPServer(ctx context.Context, config parser.RegistryMCPServerConfig, verbose bool) (*parser.MCPServerInfo, error) {
...
if config.Container != "" {
cmd = exec.Command("docker", args...) // line 150 -> exec.CommandContext(ctx, "docker", args...)
} else {
cmd = exec.Command(config.Command, config.Args...) // line 155 -> exec.CommandContext(ctx, config.Command, config.Args...)
}
...
}Why this is a real improvement
The *exec.Cmd is handed to mcp.CommandTransport; binding it via exec.CommandContext(ctx, ...) ensures the spawned MCP server process is terminated when the 30s timeout (or any future cancellation) fires, instead of leaking until it exits on its own.
Remaining prerequisites for enforcement
Enforce-readiness checklist
- Fix the nil-guard false positive (execcommandwithoutcontext precision: false positive on nil-guarded exec.Command fallback — autofix injects a nil context that pa
[Content truncated due to length] #38281) —
pkg/workflow/github_cli.go:32is mis-flagged; enforcing now would either break CI or force an unsafe autofix. Blocker. - Add
internal/nolintsupport —execcommandwithoutcontextdoes not importpkg/linters/internal/nolint(unlike the 12 enforced linters), so//nolint/redaction directives are silently ignored. Wirenolint.BuildLineIndex+ per-diagnostic suppression as the other linters do, to match parity. - Convert the 2 genuine sites above.
- Enforce: append
-execcommandwithoutcontexttoLINTER_FLAGSin.github/workflows/cgo.yml:1122(currently 12 flags), making it the 13th enforced linter.
Recommendation
Convert the 2 connectStdioMCPServer sites in this issue. Track the FP fix in #38281 and the nolint parity + CI flag as the final enabling steps (do not enforce until both #38281 and nolint support land).
Validation checklist
-
mcp_inspect_mcp.go:150and:155useexec.CommandContext(ctx, ...). - MCP inspect still connects to stdio/docker servers (manual smoke or existing tests).
-
execcommandwithoutcontextimportsinternal/nolintand honors//nolintdirectives. - After execcommandwithoutcontext precision: false positive on nil-guarded exec.Command fallback — autofix injects a nil context that pa
[Content truncated due to length] #38281 lands, repo-wide run of
execcommandwithoutcontextis clean, then CI flag added.
Effort: Small for the 2 conversions; Medium overall including nolint wiring. Gated on #38281.
References: §27254549539
Generated by 🤖 Sergo - Serena Go Expert · 294.4 AIC · ⌖ 14.5 AIC · ⊞ 6.3K · ◷
- expires on Jun 16, 2026, 9:18 PM UTC-08:00
Activity
github-actions commentedon Jun 10, 2026
🍪 Issue Monster selected this for Copilot
I have identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪
Copilot commentedon Jun 10, 2026
The agent encountered an error and was unable to start working on this issue: Please try again later, or contact support if the problem persists. (Request id: 1BC2:11492D:37D4FB:D3487F:6A29C8CF)
github-actions commentedon Jun 10, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪
github-actions commentedon Jun 17, 2026
This issue was automatically closed because it expired on 2026-06-17T05:18:59.386Z.