Repository navigation
Description
Summary
Three production sites compare a Context.Err() return value to context.Canceled / context.DeadlineExceeded with ==, while the rest of the codebase (including production code in the same package family) consistently uses errors.Is. This is a low-severity but real idiom inconsistency: == only happens to work because Context.Err() is documented by the standard library to return exactly one of those sentinels — any future wrapper (e.g., context.Cause, a custom context wrapper) would silently break these checks. Filed by Sergo Run 15.
Affected sites
| File | Line | Current | Recommended |
|---|---|---|---|
pkg/cli/actionlint.go |
310 | if runCtx.Err() == context.DeadlineExceeded { |
if errors.Is(runCtx.Err(), context.DeadlineExceeded) { |
pkg/cli/actionlint.go |
320 | if runCtx.Err() == context.Canceled { |
if errors.Is(runCtx.Err(), context.Canceled) { |
pkg/cli/mcp_validation.go |
205 | if ctx.Err() == context.DeadlineExceeded { |
if errors.Is(ctx.Err(), context.DeadlineExceeded) { |
Evidence of existing convention
The codebase already uses errors.Is for this exact comparison in multiple files — production and test — proving this is the established idiom:
pkg/cli/trial_helpers.go:93—errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded)(production)pkg/cli/pr_automerge_test.go:46,pkg/cli/logs_orchestrator_test.go:141,pkg/cli/logs_parallel_test.go:299,pkg/cli/mcp_server_stdio_integration_test.go:78,pkg/cli/run_workflow_execution_test.go:110,185(tests)
For reference, io.EOF comparisons in the codebase are 100% on the errors.Is side already (2/2 sites): pkg/fileutil/tar.go:34, pkg/cli/experiments_command.go:775.
Severity
Low — current code is functionally correct because Context.Err() is contractually guaranteed by stdlib to return an unwrapped sentinel. The fix is idiom consistency and futureproofing, not a bug fix.
Recommended fix
Replace the three == checks with errors.Is. The errors package is already imported in both files (used by errors.New(...) calls nearby).
// pkg/cli/actionlint.go
if errors.Is(runCtx.Err(), context.DeadlineExceeded) { ... }
if errors.Is(runCtx.Err(), context.Canceled) { ... }
// pkg/cli/mcp_validation.go
if errors.Is(ctx.Err(), context.DeadlineExceeded) { ... }Validation
-
go vet ./...clean -
go test ./pkg/cli/...passes (existing timeout tests must still pass) - Grep confirms zero remaining
\.Err\(\) == context\.matches inpkg/
Estimated effort
Small — 3 line-level edits in 2 files, no behaviour change.
Why now
Sergo Run 13 introduced the errstringmatch linter and Run 14 cleaned up the seven prod violations, establishing a clear project value for migrating away from brittle error-shape matching. The == against context sentinels is the same family of anti-pattern at a smaller scale — easy to clean up in the same theme.
Generated by Sergo Run 15 — strategy: open-issue-reverify + error-comparison-idiom-audit. Auto-closes after 7 days per create-issue.expires: 7d.
Generated by 🤖 Sergo - Serena Go Expert · ● 15.3M · ◷
- expires on May 28, 2026, 5:14 AM UTC
Activity
github-actions commentedon May 21, 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! 🍪