Skip to content

fix(cargo): pass through --message-format=json output without text filtering - #2750

Closed
guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:fix/cargo-message-format-json
Closed

guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:fix/cargo-message-format-json

Conversation

@guyoron1

Copy link
Copy Markdown
Contributor

Summary

  • CargoBuildHandler uses text patterns (Compiling, error[, Finished) that don't match NDJSON lines, so --message-format=json builds report "compiled" even on failure and hide all compiler errors
  • Detect --message-format=json (and json-diagnostic-rendered-ansi, json-render-diagnostics) in args and bypass text filtering, passing raw JSON output unchanged
  • Applies to both cargo build and cargo check (same handler)

Fixes #2419

Test plan

  • Added 9 unit tests for has_json_message_format detection (inline =, space-separated, all JSON variants, negative cases)
  • cargo test --all passes (2244 pass, 2 pre-existing unrelated failures)
  • Manual verification: failing build with --message-format=json now shows error diagnostic JSON + "success":false + exit 101
  • Manual verification: successful build with --message-format=json shows artifact JSON + "success":true + exit 0
  • Non-JSON builds continue filtering normally

…ltering

CargoBuildHandler uses text patterns (Compiling, error[, Finished) that
don't match NDJSON lines, so build errors are invisible and the build is
reported as compiled when --message-format=json is active.

Detect --message-format=json (and json-diagnostic-rendered-ansi,
json-render-diagnostics) in args and bypass text filtering for both
cargo build and cargo check, preserving raw JSON output unchanged.

Fixes rtk-ai#2419
@KuSh

KuSh commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Hi, thanks for your work. There’s already #2422, which is more complete since it doesn’t give up on reducing JSON output. It should definitely include your args detection too. Feel free to test it and share any feedback there

@guyoron1

Copy link
Copy Markdown
Contributor Author

Thanks for pointing out #2422 — happy to close this one in favor of the more complete approach there. Let me know if there's anything from my args detection logic worth cherry-picking into that PR.

@guyoron1

Copy link
Copy Markdown
Contributor Author

Superseded by #2422 which handles --message-format=json more completely.

@guyoron1 guyoron1 closed this Jul 24, 2026
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.

rtk cargo build --message-format=json reports a failed build as "compiled" and hides the error

2 participants