Completed path-scoped scan fails to save: "scan.target.kind: must match the workbench target" (recorded as failed preflight)

Author: sidoyuCreated Jul 29, 2026Updated Sep 9, 2026
Labelsbugpriority:p1area:reportsarea:cost

Summary

A path-scoped standard scan completed its full analysis (threat model, discovery over all in-scope files, validation, findings authored), but the final save/seal step failed with scan.target.kind: must match the workbench target. The CLI exits 2, the scan is left unsealed, and scan history records it as status: failed / phase: preflight even though ~13 minutes of analysis completed and token usage was recorded. Possibly related to #20 (same "Could not save the Codex Security scan" family, different message).

Environment

  • Codex Security CLI: 0.1.1
  • Node.js: 26.0.0
  • Python: 3.14.5
  • OS: macOS (Apple Silicon)
  • Authentication: stored ChatGPT credentials

Reproduction steps

Path-scoped standard scan of a git worktree (fresh, empty output directory):

bash
codex-security scan /path/to/repository \
  --model gpt-5.6-luna \
  --codex 'model_reasoning_effort="medium"' \
  --path app \
  --max-cost 3 \
  --output-dir /path/outside/fresh-results \
  --json

--dry-run for the same command reports target.kind: paths.

Observed behavior

The scan ran ~13 minutes, reviewed all 38 in-scope files, and authored findings.json (3 findings), coverage.json, and scan-manifest.json. Then:

[13:17] Running scan: app
codex-security: Could not save the Codex Security scan: scan.target.kind: must match the workbench target
codex-security: Partial output was kept at /path/outside/fresh-results.

Exit code 2. Additional inconsistencies in the partial output:

  • The authored scan-manifest.json says Target kind: git_worktree while the CLI/workbench registered the target as paths — which appears to be the mismatch that the save step rejects.
  • scans list records the scan as progress.phase: preflight, status: failed, findingCount: 0, coverage.closedRows: 0, even though cost/tokens were fully recorded and findings exist on disk.
  • The output directory contains intermediate per-slice artifacts (e.g. a scan-artifacts/ tree with a 0-result results.sarif and a findings.json with a different scan ID) alongside the root-level canonical findings.json with 3 findings, which is easy to misread after the failed seal.

Expected behavior

Either the agent-authored manifest should use the target kind the workbench registered (paths), or the save step should reconcile the two. A completed analysis should not be recorded as a failed preflight, and exit 2 after a fully completed analysis makes the exit code unusable for CI policy decisions.