Skip to content

Commit 2b2d87c

Browse files
authored
fix: allow completion when no draft manifest exists yet (#83)
Fresh recipe-driven scans fail at completion with: Could not save the Codex Security scan: scan-manifest.json: expected a regular file inside the scan directory. `workbench_db.complete_scan` reads `scan-manifest.json` with `required=True` when `scan.recipe_json is not None`, but on a first completion of a fresh scan there is no prior draft on disk yet — the draft is authored later by `_write_prepared_scan_finalization`. The read therefore always raises before the write can happen, and every retry still throws before writing anything, so `scan_dir` stays empty and models are billed with no artifacts produced. Make the pre-write read optional. When a prior manifest is present (resumed / re-completed scans), preserve the sealed timestamps as before; otherwise skip that step and let the downstream finalizer write the draft. Verified against `pnpm run lint` (tsc --noEmit) and the full `bun test` suite on the public SDK: 367 pass, 23 expected skips, 0 fail. Refs #73
1 parent be60e8f commit 2b2d87c

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

sdk/typescript/_bundled_plugin/scripts/workbench_db.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,11 +1414,18 @@ def complete_scan_locked(
14141414
completion_timestamp = now()
14151415
completion_binding = workbench_completion_binding(scan, completion_timestamp)
14161416
if scan["recipe_json"] is not None:
1417-
manifest = read_json_object(artifact_path(scan_dir, ARTIFACTS["manifest"], required=True))
1418-
manifest_scan = manifest.get("scan")
1419-
if isinstance(manifest_scan, dict) and manifest_scan.get("sealedAt") is not None:
1420-
completion_binding["startedAt"] = manifest_scan.get("startedAt")
1421-
completion_binding["completedAt"] = manifest_scan.get("completedAt")
1417+
# Fresh recipe-driven scans have no prior scan-manifest.json on disk — the
1418+
# draft is authored later by _write_prepared_scan_finalization. Guard the
1419+
# read so first-time completion does not fail with "expected a regular
1420+
# file inside the scan directory" (issue #73). When a prior manifest does
1421+
# exist (resumed / re-completed scans), preserve the sealed timestamps.
1422+
manifest_path = artifact_path(scan_dir, ARTIFACTS["manifest"], required=False)
1423+
if manifest_path is not None:
1424+
manifest = read_json_object(manifest_path)
1425+
manifest_scan = manifest.get("scan")
1426+
if isinstance(manifest_scan, dict) and manifest_scan.get("sealedAt") is not None:
1427+
completion_binding["startedAt"] = manifest_scan.get("startedAt")
1428+
completion_binding["completedAt"] = manifest_scan.get("completedAt")
14221429
try:
14231430
prepared = _prepare_scan_finalization(
14241431
scan_dir,

0 commit comments

Comments
 (0)