Skip to content

Cargo stage options --json & --strict - #91

Merged
MusicalNinjaDad merged 29 commits into
mainfrom
cargo_options
Aug 25, 2026
Merged

Cargo stage options --json & --strict#91
MusicalNinjaDad merged 29 commits into
mainfrom
cargo_options

Conversation

@MusicalNinjaDad

Copy link
Copy Markdown
Owner

closes #88

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="ninja-xtask/src/commands/mod.rs" line_range="78-82" />
<code_context>
+
+        let status = output.status;
+        let json = flags.contains(CheckFlags::JSON).then(|| {
+            let payload = String::from_utf8_lossy(&output.stdout)
+                .lines()
+                .filter(|line| line.starts_with("{"))
+                .map(serde_json::from_str::<Value>)
+                .map(|json| json.unwrap_or_else(|err| json!({"unparsable": &err.to_string()})))
+                .collect::<Value>();
+            json!({
</code_context>
<issue_to_address>
**issue (bug_risk):** JSON-mode command results are built exclusively from `output.stdout`, while `output.stderr` is discarded for failed commands; a subprocess that reports its failure only on stderr produces JSON containing just an empty payload and no diagnostic text.

**Triggers:** When a stage command exits unsuccessfully without emitting parseable JSON on stdout.

**Suggested fix:** Include stderr in the JSON result, either as a dedicated field or by converting non-JSON stderr lines into structured error entries.

```suggestion
            json!({
                "task": task,
                "status": &status.to_string(),
                "payload": payload,
                "stderr": String::from_utf8_lossy(&output.stderr).to_string(),
            })
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: ninja-xtask/src/commands/mod.rs:82


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread ninja-xtask/src/commands/mod.rs
@MusicalNinjaDad
MusicalNinjaDad merged commit 60dc44c into main Aug 25, 2026
9 checks passed
@MusicalNinjaDad
MusicalNinjaDad deleted the cargo_options branch August 25, 2026 05:10
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.

json output

1 participant