Skip to content

fix(cli): emit ok:false envelope for failed history commands - #562

Merged
mldangelo-oai merged 2 commits into
openai:mainfrom
pasmud:gaz/codex-security
Aug 20, 2026
Merged

fix(cli): emit ok:false envelope for failed history commands#562
mldangelo-oai merged 2 commits into
openai:mainfrom
pasmud:gaz/codex-security

Conversation

@pasmud

@pasmud pasmud commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

A failed structured history command exited non-zero and reported an error on stderr, but still emitted an ok: true envelope on stdout. This made automation that consumes structured stdout incorrectly classify failed commands as successful. This change makes the CLI emit an ok: false error envelope on failure instead.

Changes

In sdk/typescript/src/cli.ts, the history helper previously caught workbench failures, wrote the error to stderr, set the exit code to 2, and returned undefined. Because it returned normally, the Incur command framework produced a successful envelope with ok: true. The helper now re-throws the error so the framework emits an ok: false envelope. The scans match catch block was updated the same way for consistency.

Testing

  • Added a regression test in sdk/typescript/tests-ts/cli.test.ts covering scans show, scans list, scans compare, and scans match with --json: each asserts exit code 2, empty stdout (no ok: true), and the error on stderr.
  • bun test --timeout 30000 tests-ts/cli.test.ts: 140 pass, 0 fail.
  • tsc --noEmit: clean.

Risk and rollout

Low. The change only affects the structured envelope emitted for already-failing history commands; successful commands are unchanged. No schema or persisted-state changes.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@pasmud

pasmud commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi @soyeon-oai , could you please review this PR when you have a chance?

@mldangelo-oai mldangelo-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great! thank you

@mldangelo-oai
mldangelo-oai merged commit 6ec8c94 into openai:main Aug 20, 2026
51 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants