fix: preserve structured API error status metadata - #84
Conversation
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. |
There was a problem hiding this comment.
🟡 Changes recommended
errorType is forwarded without runtime type/emptiness validation, which can violate the advertised structured JSON contract for automation consumers.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends the CLI’s structured error JSON contract to preserve response metadata needed for automation (HTTP status, SDK-normalized status, and SDK error type), and advertises the additive capability via describe.automation.
Changes:
- Add structured error metadata (
error.httpStatusCode,error.statusCode,error.errorType) to JSON stderr for recognized SDK response errors. - Expand test coverage for metadata preservation (including localization and redaction expectations) and add packed-binary smoke coverage.
- Advertise the additive contract via
describe.automation.structuredErrorMetadataand document consumer guardrails in README + skill references.
File summaries
| File | Description |
|---|---|
| src/internal/output-service.ts | Adds extraction/serialization of structured SDK error metadata into JSON stderr. |
| src/internal/output.test.ts | Adds regression tests ensuring metadata survives localization and does not leak sensitive payloads. |
| src/internal/metadata.ts | Extends the automation contract schema with structuredErrorMetadata. |
| src/internal/metadata.test.ts | Updates describe/automation contract assertions for the new capability flag. |
| scripts/smoke-packed-install.mts | Adds packed install smoke checks for structured stderr metadata across status scenarios (incl. malformed bodies). |
| README.md | Documents the additive structured error metadata contract and safe consumer checks. |
| skills/putio-cli/SKILL.md | Updates consumer guidance to classify failures via structured metadata fields. |
| skills/putio-cli/references/guardrails.md | Documents structured error fields, their meaning, and missing-file validation rules. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f8a64cb3f
ℹ️ 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".
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
JSON errors now include HTTP status, SDK-normalized status, and API error type when available. Scripts can distinguish API failures without parsing localized messages.
describereports support; terminal output and redaction are unchanged.Verification
The missing-metadata regression failed before the fix. On
45a06f5, the canonical and pre-push gates passed 368 tests plus packed CLI checks for authentication, rate limits, differing statuses, and malformed error bodies. Independent Codex High review found no issues.Notes
Hold unmerged: main publishes a release.