openai / openai/codex-security

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

Open
#50 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cost area:reports bug priority:p1
Dominant language
TypeScript
Stars
10.8k
Forks
801
Avg merge
1d 8h
Merged PRs (30d)
257

Description

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):

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CLI scan entry point and reproduce the path-scoped command using --dry-run, then inspect scan-manifest.json, the save/seal result, and scan history. Trace how the registered target kind and authored manifest are compared and how completion is recorded; done means the completed scan seals successfully, records the correct status and findings, and returns a usable exit code.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.