Skip to content

fix: preserve structured API error status metadata - #84

Open
altaywtf wants to merge 4 commits into
mainfrom
fix/structured-api-error-status
Open

fix: preserve structured API error status metadata#84
altaywtf wants to merge 4 commits into
mainfrom
fix/structured-api-error-status

Conversation

@altaywtf

@altaywtf altaywtf commented Sep 6, 2026

Copy link
Copy Markdown
Member

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. describe reports 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.

Copilot AI lite review requested due to automatic review settings September 6, 2026 10:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-06T10:54:22.049177Z 8f8a64c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI 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.

🟡 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.structuredErrorMetadata and 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.

Comment thread src/internal/output-service.ts

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread src/internal/output-service.ts
Comment thread skills/putio-cli/references/guardrails.md Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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.

2 participants