Skip to content

fix(go): respect build failure exit status - #2188

Merged
pszymkowiak merged 1 commit into
rtk-ai:developfrom
jsiu93:fix/go-build-pattern-errors
Jun 1, 2026
Merged

pszymkowiak merged 1 commit into
rtk-ai:developfrom
jsiu93:fix/go-build-pattern-errors

Conversation

@jsiu93

@jsiu93 jsiu93 commented May 31, 2026

Copy link
Copy Markdown
Contributor

Closes #2185.

Summary

  • Gate rtk go build success output on the wrapped process exit code.
  • Surface unrecognized non-zero go build output instead of reporting Go build: Success.
  • Preserve Go package-pattern/module-resolution errors such as pattern ./...: directory prefix ....

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test --all --quiet
  • Manual repro in an empty directory: target/debug/rtk go build ./...

Gate go build success output on the child exit code and surface unrecognized non-zero build output instead of reporting success.

Closes rtk-ai#2185.
@CLAassistant

CLAassistant commented May 31, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thorough fix — the diagnose matches the repro in #2185 exactly, and the two-layer approach (allow-list entry for pattern + exit-aware fallback) is the right call. The runner.rs refactor (RunMode::FilteredWithExit + shared run_captured_filter) is a particularly valuable piece: it lays the plumbing so other ecosystems can opt into exit-aware filtering without duplicating logic. Several other filters (cargo clippy, mypy, ruff, tsc, eslint, golangci-lint, go vet) have the same latent "no errors detected = Success" pattern and would benefit from the same migration.

A second independent review (code-reviewer agent) and empirical sweep across 19 commands on develop vs this branch confirmed byte-identical behavior on every non-go-build path.

A few light suggestions for follow-up, none blocking:

  1. ANSI escape codes in the failure fallback: format_go_build_failure echoes raw stderr lines through truncate without passing through strip_ansi. Real go build doesn't emit ANSI, so this is a theoretical concern, but a malicious or unusual go wrapper could inject OSC 8 hyperlinks or alt-screen sequences that survive into the LLM context. A strip_ansi call per line would close that gap cheaply.

  2. "pattern " prefix in is_go_build_error_line: matches any line starting with pattern (lowercased). A custom build tool printing pattern ./internal/...: 12 files matched would be classified as an error. Tightening to "pattern ./" or requiring ": " after the argument would eliminate that risk while still matching every real go build pattern-error shape.

  3. Tests: the new tests use assert!(result.contains(...)) — consistent with the rest of go_cmd.rs, so just a style note. Adding edge-case tests for filter_go_build_with_exit("", 1) and whitespace-only inputs would round out coverage.

  4. Follow-up opportunity (out of scope for this PR): migrating cargo clippy, mypy, ruff, tsc, eslint, golangci-lint, and go vet to run_filtered_with_exit would close the same class of bug across the rest of the codebase.

Approving — the fix is correct, the refactor is well-bounded, and behavior is preserved across every other command. Thanks for the careful work!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go build failure misreported as "Go build: Success" for package-pattern / module-resolution errors

3 participants