Skip to content

The -bench guard only matches a single dash, so go test --bench=. gets -json injected and all benchmark output is filtered away; and rtk golangci-lint maps "issues found" to exit 0 #3428

Open

Description

@HetCreep

Two Go-path defects, both reproduced.

Provenance: AI-assisted source audit, human-directed, at v0.44.2 (700bdde). Reproduced with the shipped binary against PATH stand-ins that emit real go test / golangci-lint output shapes; Go itself is not installed here.

1. --bench=. defeats the benchmark guard

src/cmds/go/go_cmd.rs:50 decides whether to skip JSON mode with a.starts_with("-bench"). Go's flag package accepts -bench and --bench identically, so the double-dash form misses the guard, -json is injected, and the test filter reduces the output to a pass/fail count.

Stand-in emitting a benchmark line:

BenchmarkParse-8   1874233   641.2 ns/op   288 B/op   6 allocs/op
PASS
ok  example/pkg  1.234s
$ rtk go test --bench=. ./...
Go test: No tests found

Every measurement — ns/op, B/op, allocs/op — is gone, and the summary says no tests were found. Control with the single-dash form, which the guard does catch:

$ rtk go test -bench=. ./...
GO-ARGV: test "-bench=." ./...
BenchmarkParse-8   1874233   641.2 ns/op   288 B/op   6 allocs/op

Someone benchmarking through an agent gets "No tests found" and no numbers.

2. golangci-lint issues are reported as success

src/cmds/go/golangci_cmd.rs:160:

Ok(if exit_code == 1 { 0 } else { exit_code })
$ golangci-lint run          # stand-in: prints issues JSON, exits 1
$ rtk golangci-lint run ; echo $?
0

The issues themselves are still printed, so this is not silent — but the exit code is what gates && chains and CI steps. rtk golangci-lint run && deploy deploys with lint issues outstanding.

The mapping is deliberate and commented in the source. I am raising it because it contradicts the exit-code propagation rule in the project's own .claude/rules/, and because the same trade-off was decided the other way for go build in f69ad6e ("respect build failure exit status"). If it was a considered decision that has not been revisited since the go build change, it may be worth making the two consistent.

Suggested fixes (untested — no programmer has reviewed these)

  1. Normalise the flag before the check — strip a leading -- down to -, or test trim_start_matches('-').starts_with("bench"). Worth sweeping the other flag guards in the Go and JS families for the same single-dash assumption.
  2. Either propagate 1, or keep the mapping and make it opt-out via a flag, so a CI user can get the real status.

Related, not verified by me

From the same review, in src/cmds/ruby/rubocop_cmd.rs:57-58: is_autocorrect lists only -a, -A, --auto-correct, --auto-correct-all — not RuboCop's equally valid --autocorrect, --autocorrect-all, -x or --fix-layout. The consequence reported to me was that --autocorrect runs get --format json injected and are routed to the JSON filter, which then advises re-running the autocorrect that just ran. I did not reproduce this one (no Ruby here and I did not build a stand-in for it), so treat it as a pointer rather than a finding — it is the same missing-alias shape as item 1 above, which is why I mention it.

Activity

  1. pszymkowiak commented on Aug 4, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    --bench (double-dash) bypasses the go test JSON-mode guard and strips benchmark output; golangci-lint exit code 1 (issues found) is mapped to 0, defeating CI && chains — fix flag matching in go_cmd.rs and reconsider the exit-code mapping in golangci_cmd.rs for consistency with go build's exit propagation.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/cmds/go/go_cmd.rs
    • src/cmds/go/golangci_cmd.rs
    • src/cmds/ruby/rubocop_cmd.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibugpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions