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

scan.target.snapshotDigest: expected a non-empty string

Open gz opened this issue 4 months ago • 5 comments

got this. not sure it's supposed to be like that:

➜ npx codex-security scan <folder> --diff origin/main --head HEAD
[00:00] Preparing scan
[00:00] Authentication: stored Codex credentials.
[00:01] Preparing scan
[00:28] Running scan: committed changes
[00:29] Preflight: worker delegation supported.
[05:17] Running scan: committed changes
[05:18] Worker capacity changed during file review; started 1 of 10 planned workers. Continuing scan.
[05:30] Running scan: reviewing files (committed changes)
[05:30] Worker capacity changed during file review; started 2 of 10 planned workers. Continuing scan.
[05:43] Running scan: reviewing files (committed changes)
[05:44] Worker capacity changed during file review; started 3 of 10 planned workers. Continuing scan.
[05:55] Running scan: reviewing files (committed changes)
[05:56] Worker capacity changed during file review; started 4 of 10 planned workers. Continuing scan.
[06:07] Running scan: reviewing files (committed changes)
[06:08] Worker capacity changed during file review; started 5 of 10 planned workers. Continuing scan.
[06:20] Running scan: reviewing files (committed changes)
[06:20] Worker capacity changed during file review; started 6 of 10 planned workers. Continuing scan.
[06:32] Running scan: reviewing files (committed changes)
[06:33] Worker capacity changed during file review; started 7 of 10 planned workers. Continuing scan.
[11:39] Running scan: reviewing files (committed changes)
[11:40] Worker capacity changed during file review; started 8 of 10 planned workers. Continuing scan.
[12:54] Running scan: reviewing files (committed changes)
[12:54] Worker capacity changed during file review; started 9 of 10 planned workers. Continuing scan.
[13:02] Running scan: reviewing files (committed changes)
[13:02] Scan phase: reviewing files (10 workers).
[29:49] Running scan: reviewing files (committed changes)
[29:50] Worker capacity changed during validation; started 9 of 13 planned workers. Continuing scan.
[29:57] Running scan: validating findings (committed changes)
[29:57] Worker capacity changed during validation; started 10 of 13 planned workers. Continuing scan.
[30:06] Running scan: validating findings (committed changes)
[30:06] Worker capacity changed during validation; started 11 of 13 planned workers. Continuing scan.
[30:14] Running scan: validating findings (committed changes)
[30:15] Worker capacity changed during validation; started 12 of 13 planned workers. Continuing scan.
[30:26] Running scan: validating findings (committed changes)
[30:26] Scan phase: validating findings (13 workers).
[42:49] Running scan: validating findings (committed changes)
[42:49] Scan phase: analyzing attack paths (9 workers).
[91:52] Running scan: analyzing attack paths (committed changes)
codex-security: Could not save the Codex Security scan: scan.target.snapshotDigest: expected a non-empty string
codex-security: Partial output was kept at <redacted>.
``

gz avatar Jul 29 '26 02:07 gz

Same here, but at the first "Runninc scan" step.

[00:00] Preparing scan
[00:00] Authentication: stored Codex credentials.
[00:02] Preparing scan
[58:48] Running scan
codex-security: Could not save the Codex Security scan: scan.target.snapshotDigest: expected a non-empty string
codex-security: Partial output was kept at ...

KnuX avatar Jul 29 '26 09:07 KnuX

I can reproduce this error with two clean, detached repositories.

Reproduction 1, linked worktree:

git worktree add --detach <path> <commit>
cd <path>
codex-security scan

Reproduction 2, standalone clone:

git clone --no-hardlinks --no-checkout <repository> <path>
cd <path>
git checkout --detach <commit>
codex-security scan

In both cases:

  • git status --porcelain was empty.
  • The scan completed its analysis before failing during final save.
  • The same error appeared:
codex-security: Could not save the Codex Security scan: scan.target.snapshotDigest: expected a non-empty string
codex-security: Partial output was kept at <redacted>.

The partial manifests did not contain a populated target or snapshot digest:

{
  "target": null,
  "snapshotDigest": null
}

The standalone clone had a normal .git directory, so this does not appear limited to linked-worktree metadata. Detached HEAD may be relevant.

Expected:

  • A clean, immutable target should save successfully.
  • If detached HEAD is unsupported, preflight should fail before the full scan runs.

EmilMN avatar Jul 29 '26 11:07 EmilMN

Confirmed with @openai/codex-security 0.1.6 and 0.1.7; 0.1.7 bundles Codex Security plugin 0.1.15.

The failure appears to be a contract mismatch in the published package:

  • committed commit/range diff setup records baseRevision and headRevision but no contentDigest;
  • manifest construction consequently emits a git_diff target with base/head and no snapshotDigest;
  • finalize_scan_contract.py nevertheless lists snapshotDigest as the required coordinate for every git_diff;
  • scan-manifest.schema.json likewise requires snapshotDigest for git_diff;
  • working-tree diffs separately calculate and validate a content digest.

This makes canonical finalization impossible for a committed base/head diff even when analysis completes.

Should the canonical contract instead require baseRevision and headRevision for git_diff, with snapshotDigest additionally enforced by the workbench for working-tree material?

Is this already corrected in hosted plugin 0.1.16/0.1.17? If so, which upcoming @openai/codex-security npm release will bundle the corrected plugin?

niklas-stake avatar Aug 06 '26 14:08 niklas-stake

Confirmed again with Codex Security plugin 0.1.18 on a committed base/head range.

The analysis completed, and the failure occurred only during canonical finalization with:

scan.target.snapshotDigest: expected a non-empty string

The preserved partial output was still useful as advisory evidence, but not as an officially sealed scan result.

A safe operational workaround until #241 lands is:

  1. Preserve the partial-output directory unchanged.
  2. Hash the emitted artifacts and inspect them read-only.
  3. Verify that the manifest is bound to the intended base/head revisions.
  4. Verify coverage mechanically, including that all planned work items are closed and that no areas are deferred or open.
  5. Evaluate the emitted findings and coverage artifacts for triage.
  6. Label the result explicitly as unsealed.

Important limitations:

  • Do not invent, inject, or manually substitute a snapshotDigest.
  • Do not modify the manifest to make schema validation pass.
  • Do not represent the partial result as CODEX_SECURITY_GATE:PASS.
  • Any release-policy exception for the missing technical seal must be separately authorized and bound to the exact reviewed revisions; it is not a substitute for unknown or incomplete coverage.

For a terminally failed scan, I could not find an exposed in-place recovery path for the same scan ID. Starting/rejoining may therefore create a replacement scan rather than repairing the completed analysis. A supported same-scan recovery/finalization operation would be useful in addition to the digest fix.

pharmatorium avatar Aug 11 '26 19:08 pharmatorium

Thanks for documenting this. The committed-diff snapshotDigest failure is also tracked in #299, and #449 covers the remaining finalization and snapshot-binding work. I am closing this as a duplicate so follow-up stays in one place. The older detached-checkout case was addressed separately in #103.

mldangelo-oai avatar Aug 15 '26 07:08 mldangelo-oai