{"record":{"id":"cb7069e88082fd12","repo":"HKUDS/DeepTutor","slug":"operation-not-found","errorCode":null,"errorMessage":"Operation not found","messagePattern":"Operation not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"deeptutor/api/routers/co_writer.py","lineNumber":494,"sourceCode":"@router.get(\"/history\")\nasync def get_history():\n    \"\"\"Get all operation history\"\"\"\n    try:\n        history = load_history()\n        return {\"history\": history, \"total\": len(history)}\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.get(\"/history/{operation_id}\")\nasync def get_operation(operation_id: str):\n    \"\"\"Get single operation details\"\"\"\n    try:\n        history = load_history()\n        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:","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/co_writer.py#L476-L512","documentation":"404 raised by GET /co-writer/history/{operation_id} when no history entry has a matching 'id' field. The endpoint linearly scans load_history() output and returns 404 if the loop completes without a hit.","triggerScenarios":"GET /co-writer/history/<id> where <id> is not present in any history entry — wrong id, history reset, or entry expired/rotated out.","commonSituations":"Stale operation id held in the UI after a server restart or history wipe, typo in the id, or history file replaced.","solutions":["Verify the id by listing GET /co-writer/history and matching ids","If history was reset, re-run the operation to generate a new id","Handle 404 in the client by removing stale references from the UI"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp = client.get(f'/co-writer/history/{op_id}')\nif resp.status_code == 404:\n    # stale op id — refresh from GET /co-writer/history\n    refresh_history()","preventionTips":["Always source operation ids from the history endpoint response","Drop stored ids after server restarts or history resets"],"tags":["co-writer","http-404","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}