fix(cli): emit structured JSON errors for failed scans - #709
fix(cli): emit structured JSON errors for failed scans#709Hughhhhcoder wants to merge 4 commits into
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ce5e09772
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (format === "json" || format === "jsonl") { | ||
| return { | ||
| status: "failed", | ||
| code: "SCAN_FAILED", | ||
| message: safeErrorMessage(outcome.error), |
There was a problem hiding this comment.
Document the structured failure response
For automation using the advertised scan --schema discovery flow, this introduces a new public JSON/JSONL response contract (status, code, and message) without updating the generic scan output schema or documenting the failure shape and exit semantics in sdk/typescript/README.md; consumers therefore cannot discover or reliably generate types for the new contract. Update the relevant schema and CLI documentation alongside the implementation.
AGENTS.md reference: AGENTS.md:L40-L41
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 7f681ac. The scan command schema now advertises the structured {status: "failed", code: "SCAN_FAILED", message} output variant, sdk/typescript/README.md documents the stdout/stderr and exit-code semantics, and the CLI schema regression test verifies the failure shape. Focused checks pass: Prettier, TypeScript, and the schema/output Bun tests.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #375
Summary
scan --jsonandscan --format jsoncould exit with status 2 while writing nothing to stdout when the scan failed. This made automation report an ambiguous invalid or empty response.Changes
{ status: "failed", code: "SCAN_FAILED", message }result for JSON and JSONL scan failures.--json,--format json, and--format jsonl.Testing
bun test --timeout 30000 ./tests-ts/cli.test.ts -t "emits structured failures for machine-readable scan output"(1 passed)bun test --timeout 30000 ./tests-ts/cli-authentication.test.ts(27 passed)cli.test.tsrun: 143 passed; 2 unrelated configuration-documentation tests failed in the sparse local checkout/environment.Risk and rollout
This is a CLI-only additive output change for machine-readable scan failures. Text output and non-scan commands are unchanged. The process still exits nonzero, and error messages are passed through the existing safety filter before JSON serialization.
Public disclosure review