{"record":{"id":"54021f27984449e4","repo":"shareAI-lab/learn-claude-code","slug":"resume-snapshot-not-found-for-run-id","errorCode":null,"errorMessage":"resume snapshot not found for {run_id}","messagePattern":"resume snapshot not found for (.+?)","errorType":"validation","errorClass":"WorkflowInputError","httpStatus":null,"severity":"error","filePath":"s16_workflow_runtime/code.py","lineNumber":623,"sourceCode":"        })\n        _save_last_run(run_id)\n        task.event(\"task_notification\", status=task.status,\n                   agents=task.usage[\"agents\"], tokens=task.usage[\"tokens\"],\n                   outputFile=f\".runtime/{run_id}.output.json\")\n        return {\"launched\": launched, \"result\": result, \"task\": task}\n\n\ndef _write_json(path, value):\n    path.parent.mkdir(parents=True, exist_ok=True)\n    temporary = path.with_suffix(path.suffix + \".tmp\")\n    temporary.write_text(json.dumps(value, indent=2, default=str))\n    os.replace(temporary, path)\n\n\ndef _read_snapshot(run_id):\n    path = STORE / f\"{run_id}.json\"\n    if not path.exists():\n        raise WorkflowInputError(f\"resume snapshot not found for {run_id}\")\n    try:\n        snapshot = json.loads(path.read_text())\n    except json.JSONDecodeError as exc:\n        raise WorkflowInputError(f\"invalid resume snapshot for {run_id}\") from exc\n    if not isinstance(snapshot, dict):\n        raise WorkflowInputError(f\"invalid resume snapshot for {run_id}\")\n    return snapshot\n\n\ndef _save_last_run(run_id):\n    (STORE / \"last_run.txt\").write_text(run_id)\n\n\ndef _read_last_run():\n    p = STORE / \"last_run.txt\"\n    return p.read_text().strip() if p.exists() else None\n\n","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/shareAI-lab/learn-claude-code/blob/985456f4adea6f4df8fbad4112245dbd97444eae/s16_workflow_runtime/code.py#L605-L641","documentation":"_read_snapshot(run_id) loads STORE/<run_id>.json; if the file does not exist it raises WorkflowInputError('resume snapshot not found for <run_id>'). Snapshots live under the module's .runtime directory and are what make resume possible, so a missing file means the run identity cannot be resumed on this machine.","triggerScenarios":"Calling run_workflow(..., resume_from_run_id=id) where id was never launched here, was launched in a different STORE directory, or the .runtime directory was cleaned.","commonSituations":"Resuming on a different machine/container than where the run executed; CI cleaning the workspace between jobs; a truncated or mistyped runId; STORE path resolved differently (module relocated).","solutions":["Verify STORE/<run_id>.json exists (STORE is s16_workflow_runtime/.runtime) and the runId is copied exactly.","If the snapshot is genuinely gone, re-run the workflow from scratch — resume is impossible without the snapshot.","Persist/restore the .runtime directory (snapshot + journal together) when runs cross machines or CI steps."],"exampleFix":"# before\nawait run_workflow(\"review\", resume_from_run_id=\"wf_review_deadbeef\")  # typo'd id\n\n# after\nrid = _read_last_run()  # or copy the exact id from the launch output\nawait run_workflow(\"review\", resume_from_run_id=rid)","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfrom s16_workflow_runtime import STORE, RUN_ID_RE\nassert RUN_ID_RE.match(run_id), f\"malformed runId: {run_id}\"\nsnap = STORE / f\"{run_id}.json\"\nif not snap.exists():\n    raise FileNotFoundError(f\"cannot resume: no snapshot at {snap}\")","typeGuard":"def is_resumable(run_id: str) -> bool:\n    return (STORE / f\"{run_id}.json\").exists()","tryCatchPattern":"try:\n    await run_workflow(name, resume_from_run_id=rid)\nexcept WorkflowInputError as e:\n    if \"snapshot not found\" in str(e):\n        return await run_workflow(name, args=args)  # cold start\n    raise","preventionTips":["Validate the runId shape (RUN_ID_RE) before attempting a resume.","Treat s16_workflow_runtime/.runtime as run-critical state: back it up, keep it on the same host as the run.","Surface the launched runId in your own logs next to the workflow name so resumes never guess."],"tags":["workflow","resume","snapshot","file-not-found","persistence"],"backgroundTag":null,"analyzedSha":"985456f4adea6f4df8fbad4112245dbd97444eae","analyzedAt":"2026-08-14T22:02:26.028Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}