Skip to content

fix(cli): avoid claiming output was kept after scan failures - #359

Merged
mldangelo-oai merged 19 commits into
openai:mainfrom
Mr-Neutr0n:fix/empty-partial-output-message
Oct 30, 2026
Merged

mldangelo-oai merged 19 commits into
openai:mainfrom
Mr-Neutr0n:fix/empty-partial-output-message

Conversation

@Mr-Neutr0n

@Mr-Neutr0n Mr-Neutr0n commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A failed or interrupted scan could say it kept partial output merely because it had a configured directory. That directory can be empty, contain staged inputs, or belong to a subsequent scan after the first one was archived.

Addresses the misleading output diagnostic in #191, #73, and #20. Those issues continue to track failures to produce draft artifacts.

Changes

  • Give the known output directory on scan failure and interruption. An interruption before archive registration can use the directory already carried by the SDK error. Omit the unverified retention flag from verbose failure and interruption diagnostics.
  • Preserve the original failure and cancellation flow, budget details, scan ID, and saved validation data. If follow-up validation is interrupted, identify both the original directory and the completed scan by ID. Its report diagnostic gives the path the CLI opened, including a generated filename.

Testing

Verified locally on 960b3988a33f73be2a74d97892d63cd6920b26cc against main at 0aeb39d501e03f4f3a9374dbc6d8d44940af0d46.

  • Ran the built CLI with its bundled plugin and Python workbench. A healthy Standard mock scan completed and wrote its artifacts. Failed database registration and a failed first manifest write each exited 2 with the original error and an empty directory. Both identified the configured location, and the registered failure retained its working saved-scan navigation.
  • Sent SIGINT inside the packaged Python workbench’s archive-registration routine, before the CLI received any directory or scan ID callback. The process exited 130 and printed its known destination. The previous report stayed in place and the workbench registered zero new scans. A separate early cancellation with no directory printed the cancellation message alone. The CLI unit test stubs registration with a nested output path. The packaged reproduction uses the supported sibling directory layout.
  • Reproduced two real SIGINT and archive races with an empty replacement and with a replacement containing a later scan’s artifacts. Both exited 130 and kept the original scan ID.
  • Interrupted follow-up validation before any assessment completed and after the first completed assessment. The CLI retained the opened report path and the completed scan ID. An optional report-path write failure preserved exits 130 and 143 and the full saved JSON on Node 22 and 24.
  • Nineteen scoped regression cases failed on unchanged main and passed with only the production change applied. All 115 tests in the CLI failure, signal, navigation and SDK error suites passed, as did 20 focused CLI tests. SDK types, formatting, CI compilation, universal packaging and the production build passed.
  • Two full local Linux SDK runs (seeds 3817699821 and 12345) each ran 7,126 tests across 238 files. Each recorded 7,037 passes, 83 skips, six failures, and four child-process cleanup errors following timeouts. All six failures and the cleanup errors reproduced on unchanged main under the same restrictions.
  • The two sandbox configuration tests passed on both revisions in a private environment that allowed Codex to create its sandbox. The four native configuration tests exceeded their 30-second limit when offline DNS silently dropped model-discovery queries. They passed on both revisions within that limit when the private resolver returned immediately.
  • Hosted source CI passed on this commit. Its six Linux SDK shards recorded 7,043 passes, 81 skips, and zero failures or errors. Source workflow

Risk and rollout

The CLI uses the directory and scan ID already available on the existing failure and cancellation paths. Existing automation that parses the verbose partial_output field will see it omitted. As with other saved-scan commands, an installation that requires an explicit Python interpreter can set PYTHON for scans show. The original directory remains visible.

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.

@github-actions github-actions Bot added the bug Something isn't working label Aug 12, 2026

@ting-hong-shieh ting-hong-shieh 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.

Reviewed at 79e9fe1a569696160fe5d2e46d73f600e9155bc8. The new empty/non-empty directory cases work, but the same misleading retained-output claim remains when the path no longer exists.

Validation snapshot:

  • Exact head and a clean synthetic merge onto current main (216212b70a421b0bf30319d241de47a64050ec0f) both pass the two existing focused tests, TypeScript checking, formatting, and git diff --check.
  • The same missing-path fixture fails on both trees. Its structured result is exit 2 / claimed=true, SIGINT 130 / claimed=true, and SIGTERM 143 / claimed=true.
  • On the current-main merge, treating ENOENT as no retained output makes all three cases pass. The PR's empty/non-empty test, TypeScript checking, formatting, and whitespace check remain clean.

I left one blocking inline finding. No model or provider call, API request, credential, or external service was used.

Comment thread sdk/typescript/src/cli.ts Resolved

Copy link
Copy Markdown
Collaborator

@codex review exact head 79e9fe1

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 79e9fe1a56

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: 79e9fe1a56

ℹ️ 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 sdk/typescript/src/cli.ts Resolved
Comment thread sdk/typescript/src/cli.ts Resolved
@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

Pushed a small update. ENOENT now counts as no retained output, with regression coverage for failed scans and SIGINT/SIGTERM after the output directory disappears. The branch is synced with current main; focused CLI tests, type checks, formatting, and the package build pass. Re-requesting review. If this is no longer a priority, no problem at all, just say the word and I will close.

@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

Also addressed the two follow-up edge cases from the automated review in 1ca3c2f. Partial-output detection now reads one directory entry and closes the handle, and cost-limit failures report no partial output when the directory is empty. The full CLI suite passes (143 tests), package build, type checks, formatting, and the changed-line secret scan pass. No force-push was used.

@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

Rebased and resolved the conflicts.

@Mr-Neutr0n
Mr-Neutr0n force-pushed the fix/empty-partial-output-message branch from 1ca3c2f to 574cfde Compare August 24, 2026 06:46
@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

Rebased by merging current main and resolved the import-only conflicts in 313743d. I also updated the signal regression fixture to create real retained output, so the ENOENT path behavior is covered. Verified 153 focused CLI/signal tests, pnpm run types, formatting, and plugin-source checks. No force-push used. Please rerun CI/review when convenient.

@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

@codex review exact head 313743d

@chatgpt-codex-connector

Copy link
Copy Markdown

Refresh the branch onto current openai/codex-security main while keeping
ENOENT-as-absent partial-output handling, single-entry directory checks,
and cost-limit empty-path messaging.

Co-authored-by: hari <[email protected]>
@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

Re-verified on current head (ab6a5d2), synced with main:

  • ENOENT is treated as no retained output in both helpers
  • Partial-output check reads a single directory entry
  • Cost-limit failures no longer claim retained output when the directory is empty
  • Focused regression coverage for missing dir + signal paths

Please re-review when convenient.

Refresh the branch onto current openai/codex-security main while keeping
ENOENT-as-absent partial-output handling, single-entry directory checks,
and cost-limit empty-path messaging aligned with short-context budget text.

Co-authored-by: hari <[email protected]>
@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

Rebased/merged onto latest main on the same fix/empty-partial-output-message branch (cf165a3). Conflicts in cli.ts / cli.test.ts are resolved — PR is MERGEABLE again.

Behavior preserved: ENOENT = no retained output (both helpers), single-entry opendir/read, cost-limit empty messaging. Cost-limit wording aligned with current short-context budget text from main. Focused partial-output + signals tests and pnpm run types pass.

Please re-review when you have a chance — thanks!

…utput-message

# Conflicts:
#	sdk/typescript/src/cli.ts
@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

Synced with main again (merge 3f4ef81, resolves the cli.ts conflict).

main had removed the dedicated cost-limit message and folded the base wording into ScanCostLimitExceededError, so I kept this PR's partial-output-aware rendering on top of the new scanFailureMessage(failure, auth, provider) signature: a cost limit that stops before anything is written still reports "no partial output was kept" with partial_output=false, and one after writing keeps the path.

Verification: tests-ts/cli.test.ts + tests-ts/cli-signals.test.ts 166 passed, tsc --noEmit clean. The six failures in the api/multiscan orchestration suites reproduce on clean main in this environment (checked in a separate worktree); they need the packaged plugin/native artifacts, not this change.

@mldangelo-oai mldangelo-oai added the area:cli Command-line help, arguments, terminal UI, and user interaction. label Oct 8, 2026
@mldangelo-oai mldangelo-oai removed the area:cli Command-line help, arguments, terminal UI, and user interaction. label Oct 8, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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 ⚠️ Failed 2026-10-30T06:08:04.501985Z
We couldn’t complete this review. Comment @codex review to try again.
de1c2a9 New commits
ℹ️ 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.

@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.

The missing-path case is fixed, and the shared output check keeps the failure paths consistent. Current-head CI passes on Linux, macOS, and Windows; the full local Linux SDK run passed (4,990 passed, 65 skipped).

…utput-message

# Conflicts:
#	plugins/codex-security/tests/test_finalize_scan_contract.py
@Mr-Neutr0n

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (3b5068428), which clears the conflict that had the PR DIRTY — it is MERGEABLE again with the approval intact.

One conflict, in plugins/codex-security/tests/test_finalize_scan_contract.py: upstream had added test_accepts_code_evidence_with_posix_colon_names where this branch had an empty block, so I took upstream's version. Nothing in this PR's own change was affected — the partial-output logic in sdk/typescript/src/cli.ts merged cleanly.

Verified on the merged head:

  • bun test ./tests-ts/cli.test.ts ./tests-ts/cli-signals.test.ts — 197 pass, 0 fail.
  • tsc --noEmit -p tsconfig.build.json clean for the SDK.
  • tsc -p tsconfig.json still reports three @modelcontextprotocol/sdk resolution errors under plugins/codex-security/mcp-app/tests/support/, because that workspace has no node_modules here; they are unrelated to this diff and reproduce on a clean checkout of main.

@mldangelo-oai mldangelo-oai changed the title fix(cli): report partial output only when present fix(cli): avoid claiming output was kept after scan failures Oct 24, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@mldangelo-oai
mldangelo-oai merged commit 11c27a4 into openai:main Oct 30, 2026
55 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 30, 2026
3 tasks
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.

4 participants