Skip to content

rtk pipe without -f reads plain go test output as find/grep results #4692

Open

Description

@KuSh

rtk pipe with no -f picks a filter from the first 1 KB. Plain-text go test ./... output matches the grep and find heuristics, so the report is rewritten as search results, and on a failing run the FAIL lines disappear.

Failing run (Go 1.24.6: 25 ok packages, a failing TestX, a package that does not compile), go test ./... 2>&1 | rtk pipe:

2 matches in 2F:

[file]     z_test.go (1):
     5: expected 1, got 2

[file] broken/b.go (1):
     3: 23: undefined: missing

No FAIL line, no package status. A green run comes out as 26 files in 2 dirs: with the package names split into a tree. With stdout only, the failing run passes through raw, because its first lines do not match.

The JSON branch is a substring test too (starts_with('{') && contains("\"Action\"")), so any JSON object with an Action key goes to the go-test filter: a pretty-printed IAM policy, or a go build -json stream, which prints Go test: No tests found.

Reproduced on develop 5538d72. rtk pipe -f go-test itself is handled in #4455.

Activity

  1. added
    bug
    on Oct 20, 2026
  2. rtk-wshm-sync-bot commented on Oct 20, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 93%

    Summary

    rtk pipe without -f mis-detects plain go test output as find/grep or JSON-go-test results, silently dropping FAIL/compile-error lines on failing runs.

    📁 Relevant files
    • src/pipe/detect.rs
    • src/pipe/filters/grep.rs
    • src/pipe/filters/find.rs
    • src/pipe/filters/go_test.rs

    Suggested Actions

    1. Tighten heuristic detection: require structural match (e.g. FAIL/ok package lines), not just substrings in first 1KB
    2. Fix JSON branch to validate full JSON Action schema, not just starts_with('{') && contains("Action")
    3. Add regression tests: failing go test run, green run, IAM policy JSON, go build -json stream
    4. Cross-reference fix(pipe): preserve non-JSON Go test reports #4455 (rtk pipe -f go-test) and go test JSON filter reports a cut-off stream as all passed #4693 (JSON filter mishandles cut-off stream) for shared root cause

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

  3. KuSh commented on Nov 2, 2026

    @KuSh
    CollaboratorAuthor

    The same detection also misses go test -json streams that have go command output in front of the first event. Go 1.27.1, go test -json ./broken ./fails 2>&1 | rtk pipe, where broken does not compile and fails has a failing test, with GODEBUG=gotestjsonbuildtext=1 so the build error comes first as text (Go 1.23 and older print it this way by default):

    # example.com/r3/broken [example.com/r3/broken.test]
    broken/b.go:3:23: undefined: missing
    {"Time":"…","Action":"start","Package":"example.com/r3/broken"}
    …
    

    rtk pipe output:

    1 matches in 1F:
    
    [file] broken/b.go (1):
         3: 23: undefined: missing
    

    The TestBad and TestSubBad failures and the package results are gone. rtk pipe -f go-test summarizes the same stream.

    Two other leading lines leave the stream unfiltered (output identical to input, nothing lost):

    • warning: no packages being tested depend on matches for pattern …, from go test -json -coverpkg=<pattern> ./… 2>&1
    • go: finding module for package … / go: found …, from a GOFLAGS=-mod=mod run that resolves a missing requirement

    Same output on v1.1.0, on develop 22812af and with #4455, which skips only blank lines and go: downloading lines before the first event.

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:clibughelp wantedpipepriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions