{"record":{"id":"e388c743c73990bc","repo":"bytedance/deer-flow","slug":"failed-to-read-latest-checkpoint","errorCode":null,"errorMessage":"Failed to read latest checkpoint","messagePattern":"Failed to read latest checkpoint","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/app/gateway/routers/thread_runs.py","lineNumber":637,"sourceCode":"            (candidate for candidate in records if getattr(candidate, \"run_id\", None) == source_run_id),\n            None,\n        )\n    if record is None:\n        return None\n    if getattr(record, \"thread_id\", None) != thread_id:\n        return None\n    if _run_status_value(record) != RunStatus.interrupted.value:\n        return None\n    return source_run_id\n\n\nasync def _prepare_regenerate_payload(thread_id: str, message_id: str, request: Request) -> RegeneratePrepareResponse:\n    accessor, latest_config = await build_thread_checkpoint_state_accessor(request, thread_id=thread_id)\n    try:\n        latest_checkpoint = await accessor.aget(latest_config)\n    except Exception as exc:\n        logger.exception(\"Failed to read latest checkpoint for regenerate thread %s\", thread_id)\n        raise HTTPException(status_code=500, detail=\"Failed to read latest checkpoint\") from exc\n    latest_checkpoint_id = _checkpoint_configurable(latest_checkpoint).get(\"checkpoint_id\")\n    if not latest_checkpoint_id:\n        raise HTTPException(status_code=404, detail=f\"Thread {thread_id} has no checkpoint\")\n\n    messages = _checkpoint_messages(latest_checkpoint)\n    target_index = next((i for i, message in enumerate(messages) if _message_id(message) == message_id), None)\n    if target_index is None:\n        # A response interrupted during an LLM call can be visible in the live\n        # stream without ever reaching a checkpoint. The server-stamped run ID\n        # on the latest user message is the durable link to that partial turn.\n        previous_human = next(\n            (message for message in reversed(messages) if _is_visible_human_message(message)),\n            None,\n        )\n        target_run_id = await _find_interrupted_target_run_id(thread_id, previous_human, request) if previous_human is not None else None\n        if target_run_id is None:\n            raise HTTPException(status_code=404, detail=f\"Message {message_id} not found\")\n    else:","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/thread_runs.py#L619-L655","documentation":"Raised in _prepare_regenerate_payload (HTTP 500) when accessor.aget(latest_config) throws while reading the thread's latest checkpoint. It is a server-side checkpointer failure (storage unreachable, deserialization error), not caused by request payload.","triggerScenarios":"Checkpoint DB outage or timeout during the regenerate-prepare call; corrupted checkpoint blob that fails deserialization; checkpointer backend restarted mid-request.","commonSituations":"Transient DB connectivity loss; checkpoint schema drift after an upgrade; misconfigured checkpointer in config.yaml.","solutions":["Read the Gateway log exception 'Failed to read latest checkpoint for regenerate thread' for the root cause.","Verify checkpointer backend health and credentials.","Repair or clear the corrupted checkpoint for that thread if deserialization is the cause.","Retry once the backend recovers."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if ((await fetch('/api/health')).status !== 200) { deferCall(); }","typeGuard":null,"tryCatchPattern":"try { await regeneratePrepare(threadId, messageId); } catch (e) { if (e.status === 500 && /read latest checkpoint/.test(e.detail)) { await backoffRetry(regeneratePrepare, threadId, messageId, 1); } else throw e; }","preventionTips":["Monitor checkpointer backend health","Retry 500s with backoff once","Surface backend logs for deserialization errors"],"tags":["checkpoint","http-500","infrastructure"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}