Repository navigation
fix: surface safe JSON command failures on stderr - #659
Merged
Merged
Conversation
Member
Author
|
@greptileai review |
|
Member
Author
|
@greptileai re-review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
JSON mode writes its machine-readable failure to stdout. Automation normally captures stdout for parsing, so a non-zero command could look silent to a human or coding agent even though Alien had an actionable typed error.
Closes ALIEN-884.
Reproduction
Run an
alien --output json ...command that returns an API error while capturing stdout. Before this change stderr has no error code, message, or request ID.Root cause
The top-level CLI converted and serialized the error only through the selected JSON output renderer. Unlike human mode, there was no terminal diagnostic channel.
Fix
JSON mode still emits the canonical machine-readable external error on stdout, and now also prints a one-line safe diagnostic on stderr containing only:
Newlines are flattened. Arbitrary error context and internal source details are deliberately excluded.
Verification
cargo test -p alien-cli json_error_diagnostic --lib -j 4Tests prove request-ID visibility, omission of secret context, and sanitization of internal errors.