{"record":{"id":"5b0454893a8f140c","repo":"shareAI-lab/learn-claude-code","slug":"resume-journal-not-found-for-run-id","errorCode":null,"errorMessage":"resume journal not found for {run_id}","messagePattern":"resume journal not found for (.+?)","errorType":"validation","errorClass":"WorkflowInputError","httpStatus":null,"severity":"error","filePath":"s16_workflow_runtime/code.py","lineNumber":333,"sourceCode":"\n\nRUNNER_FACTORY = MockAgentRunner\n\n\n# -- Journal --\nclass WorkflowJournal:\n    \"\"\"Append-only <runId>.journal.jsonl. On resume, agent() calls whose\n    semantic key is already present are replayed from cache instead of re-run.\"\"\"\n\n    def __init__(self, run_id, resume, store=None):\n        store = STORE if store is None else store\n        store.mkdir(parents=True, exist_ok=True)\n        self.path = store / f\"{run_id}.journal.jsonl\"\n        self.resume = resume\n        self.cache = {}\n        if resume:\n            if not self.path.exists():\n                raise WorkflowInputError(f\"resume journal not found for {run_id}\")\n            for line_number, line in enumerate(self.path.read_text().splitlines(), start=1):\n                try:\n                    rec = json.loads(line)\n                    if (\n                        not isinstance(rec, dict)\n                        or not isinstance(rec.get(\"key\"), str)\n                        or \"value\" not in rec\n                    ):\n                        raise ValueError(\"expected key/value record\")\n                except (json.JSONDecodeError, ValueError) as exc:\n                    raise WorkflowInputError(\n                        f\"invalid resume journal record at line {line_number}\"\n                    ) from exc\n                self.cache[rec[\"key\"]] = rec[\"value\"]\n            self._f = self.path.open(\"a\")\n        else:\n            self._f = self.path.open(\"w\")             # fresh run truncates\n","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/shareAI-lab/learn-claude-code/blob/985456f4adea6f4df8fbad4112245dbd97444eae/s16_workflow_runtime/code.py#L315-L351","documentation":"WorkflowJournal(resume=True) requires an existing <store>/<runId>.journal.jsonl to replay cached agent() results from. If the file does not exist, WorkflowInputError is raised — you cannot resume a run that never started or whose store was lost. The check happens before the journal is opened, so nothing is created or truncated on failure.","triggerScenarios":"resume(run_id) with a typo'd or hand-edited id. Resuming after the store directory was deleted, moved, or STORE was redefined (different path between runs). Resuming a run that crashed before its first journal write (the file is created on open, but a run reserved then aborted may only have <runId>.json).","commonSituations":"Store path configured per environment (local vs CI vs container volume) so the journal lives elsewhere. Cleanup jobs pruning 'old' .jsonl files. Run ids persisted in a DB but the file store is ephemeral.","solutions":["Verify the file exists first: (STORE / f\"{run_id}.journal.jsonl\").exists()","Ensure STORE resolves to the same absolute path across processes/environments","If the journal is gone, start a fresh run with reserve_run_id instead of resuming"],"exampleFix":"# before\nresult = resume(workflow, run_id=saved_id)  # journal deleted\n\n# after\nif (STORE / f\"{saved_id}.journal.jsonl\").exists():\n    result = resume(workflow, run_id=saved_id)\nelse:\n    result = run(workflow, run_id=reserve_run_id(meta))","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef journal_exists(store: Path, run_id: str) -> bool:\n    return (store / f\"{run_id}.journal.jsonl\").exists()\n\nif not journal_exists(STORE, run_id):\n    run_id = reserve_run_id(meta)  # fall back to a fresh run\nresult = resume(workflow, run_id=run_id)","typeGuard":"def is_resumable(store: Path, run_id: str) -> bool:\n    return (store / f\"{run_id}.journal.jsonl\").is_file()","tryCatchPattern":"try:\n    result = resume(workflow, run_id=run_id)\nexcept WorkflowInputError as exc:\n    if \"resume journal not found\" in str(exc):\n        result = run(workflow, run_id=reserve_run_id(meta))\n    else:\n        raise","preventionTips":["Pin STORE to one absolute path across environments","Check existence before resume()","Exclude *.journal.jsonl from cleanup/pruning jobs"],"tags":["workflow","resume","journal","filesystem"],"backgroundTag":null,"analyzedSha":"985456f4adea6f4df8fbad4112245dbd97444eae","analyzedAt":"2026-08-14T22:02:26.028Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}