shareAI-lab/learn-claude-code · error · WorkflowInputError
invalid resume snapshot for {run_id}
Error message
invalid resume snapshot for {run_id} What it means
The first 'invalid resume snapshot' variant: STORE/<run_id>.json exists but json.loads() raises JSONDecodeError, so _read_snapshot re-raises it as WorkflowInputError('invalid resume snapshot for <run_id>'). The snapshot is written atomically via a .tmp file and os.replace, so corruption almost always means external interference rather than a torn write.
Source
Thrown at s16_workflow_runtime/code.py:627
outputFile=f".runtime/{run_id}.output.json")
return {"launched": launched, "result": result, "task": task}
def _write_json(path, value):
path.parent.mkdir(parents=True, exist_ok=True)
temporary = path.with_suffix(path.suffix + ".tmp")
temporary.write_text(json.dumps(value, indent=2, default=str))
os.replace(temporary, path)
def _read_snapshot(run_id):
path = STORE / f"{run_id}.json"
if not path.exists():
raise WorkflowInputError(f"resume snapshot not found for {run_id}")
try:
snapshot = json.loads(path.read_text())
except json.JSONDecodeError as exc:
raise WorkflowInputError(f"invalid resume snapshot for {run_id}") from exc
if not isinstance(snapshot, dict):
raise WorkflowInputError(f"invalid resume snapshot for {run_id}")
return snapshot
def _save_last_run(run_id):
(STORE / "last_run.txt").write_text(run_id)
def _read_last_run():
p = STORE / "last_run.txt"
return p.read_text().strip() if p.exists() else None
# -- Sample Workflow --
FINDINGS_SCHEMA = {
"type": "object", "required": ["findings"],
"properties": {"findings": {"type": "array", "items": {View on GitHub (pinned to 985456f4ad)
Solutions
- Inspect STORE/<run_id>.json with a JSON linter to find the syntax error (commonly a trailing comma or truncated tail).
- Restore the snapshot from backup or a synced copy if the run must be resumed.
- If unrecoverable, delete the snapshot and start a fresh run (accepting full re-execution cost).
Example fix
# before: snapshot truncated to '{"workflowName": "review", "args":'
# after: repair to valid JSON
{"workflowName": "review", "args": {"changes": "..."}} Defensive patterns
Strategy: validation
Validate before calling
import json
from s16_workflow_runtime import STORE
def snapshot_parses(run_id: str) -> bool:
try:
json.loads((STORE / f"{run_id}.json").read_text())
return True
except (OSError, json.JSONDecodeError):
return False Try / catch
try:
await run_workflow(name, resume_from_run_id=rid)
except WorkflowInputError as e:
if "invalid resume snapshot" in str(e):
repair_or_backup_snapshot(STORE / f"{rid}.json") # then decide: resume vs fresh run
raise Prevention
- Never hand-edit snapshot JSON; if you must, validate with json.tool afterwards.
- Exclude .runtime from formatters/linters and version control that could rewrite files.
- Keep backups of .runtime before risky maintenance so resumes stay possible.
When it happens
Trigger: Resuming a run whose snapshot file has been truncated or mangled — crashed disk, hand-editing, a tool writing into .runtime, or encoding damage.
Common situations: Manual edits to .runtime JSON; partial file after an out-of-space event despite atomic replace of an earlier bad write; merge conflicts when the directory is checked into version control.
Related errors
- resume runId does not match workflow meta
- resume args do not match the original run
- resume snapshot not found for {run_id}
- workflow agent returned invalid JSON
- resume journal not found for {run_id}
AI-assisted analysis of shareAI-lab/learn-claude-code@985456f4ad (2026-08-14).
Data as JSON: /api/errors/c585c0c44e970cdb.
Report an issue: GitHub.