{"record":{"id":"19ab8c44a5f496a3","repo":"HKUDS/DeepTutor","slug":"tool-call-not-found","errorCode":null,"errorMessage":"Tool call not found","messagePattern":"Tool call not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"deeptutor/api/routers/co_writer.py","lineNumber":509,"sourceCode":"        for op in history:\n            if op.get(\"id\") == operation_id:\n                return op\n        raise HTTPException(status_code=404, detail=\"Operation not found\")\n    except HTTPException:\n        raise\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.get(\"/tool_calls/{operation_id}\")\nasync def get_tool_call(operation_id: str):\n    \"\"\"Get tool call details\"\"\"\n    try:\n        # Find matching file\n        for filepath in tool_calls_dir().glob(f\"{operation_id}_*.json\"):\n            with open(filepath, encoding=\"utf-8\") as f:\n                return json.load(f)\n        raise HTTPException(status_code=404, detail=\"Tool call not found\")\n    except HTTPException:\n        raise\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n# ─────────────────────────────────────────────────────────────────────────────\n# Document CRUD (multi-project Co-Writer)\n# ─────────────────────────────────────────────────────────────────────────────\n\n# Storage builds paths as `documents/doc_{doc_id}`; an unvalidated id like\n# \"a/../../x\" would escape the documents root (and DELETE runs rmtree).\n_DOC_ID_RE = re.compile(r\"^[0-9a-f]{8,32}$\")\n\n\ndef _validate_doc_id(doc_id: str) -> str:\n    if not _DOC_ID_RE.fullmatch(doc_id):\n        raise HTTPException(status_code=404, detail=\"Document not found\")","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/co_writer.py#L491-L527","documentation":"404 from GET /co-writer/tool_calls/{operation_id} when no file matching '{operation_id}_*.json' exists in the tool_calls directory. The glob pattern means the id must be the prefix of a saved tool-call file.","triggerScenarios":"GET /co-writer/tool_calls/<id> where no tool_calls/<id>_*.json file exists — unknown id, cleaned tool_calls dir, or operation that produced no tool calls.","commonSituations":"Tool-call artifacts pruned by cleanup jobs, restart with fresh data dir, or a UI holding a stale operation id.","solutions":["List the tool_calls directory (or history endpoint) to confirm which ids exist","Re-run the operation if artifacts were cleaned","Return 404 gracefully in the client"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp = client.get(f'/co-writer/tool_calls/{op_id}')\nif resp.status_code == 404:\n    skip()  # no artifacts retained for this op","preventionTips":["Expect 404 for operations that had no tool calls","Treat tool_calls as ephemeral artifacts; don't build flows that require them long-term"],"tags":["co-writer","http-404","tool-calls","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}