codex-security icon indicating copy to clipboard operation
codex-security copied to clipboard

CLI: failed structured history commands emit an ok: true envelope

Open soyeon-oai opened this issue 3 months ago • 2 comments

Summary

A failed structured history command exits non-zero and reports an error on stderr, but still emits an ok: true envelope on stdout.

Reproduction

codex-security scans show 51e818d --format json --full-output

The seven-character scan ID prefix is invalid because prefixes must contain at least eight characters.

Actual behavior

Exit code:

2

stderr:

codex-security: Could not read Codex Security scan history: Scan ID prefixes must be at least eight characters.

stdout:

{
  "ok": true,
  "meta": {
    "command": "scans show",
    "duration": "97ms"
  }
}

Expected behavior

A failed command must not emit an ok: true structured response. It should emit either an ok: false error envelope or no structured stdout, consistently with the CLI error contract.

Impact

Automation that relies on structured stdout can incorrectly classify the failed command as successful.

Environment

  • @openai/codex-security: 0.1.14
  • Reproduced twice on PR #439 head 34e687e5beda004dc9af585d8f375c5147187ffe
  • Also reproduced on base 37bf87a692fc72d41f7312cc48808d699d204fba, so this is a pre-existing issue

soyeon-oai avatar Aug 18 '26 05:08 soyeon-oai

Fixed by #562: failed structured history commands now emit an ok: false error envelope instead of ok: true.

pasmud avatar Aug 18 '26 12:08 pasmud

Verified fixed on current main at c61b46e16a2cbba53be8a93c24706deaa4b073a4 using a packed source build under Node.js 24.11.1.

Re-running the reported seven-character scan ID prefix case now produces:

  • exit code 2
  • the expected “Scan ID prefixes must be at least eight characters” error on stderr
  • empty structured stdout, rather than an ok: true envelope

Closing as fixed by #562.

soyeon-oai avatar Aug 27 '26 21:08 soyeon-oai