{"record":{"id":"a4136f8fa1d66389","repo":"odysseus-dev/odysseus","slug":"failed-to-get-upload-statistics","errorCode":null,"errorMessage":"Failed to get upload statistics","messagePattern":"Failed to get upload statistics","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"routes/upload_routes.py","lineNumber":351,"sourceCode":"                \"Upload cleanup aborted because upload index integrity could not be verified\",\n            )\n        except Exception:\n            logger.exception(\"Upload cleanup skipped because reference discovery failed\")\n            raise HTTPException(\n                503,\n                \"Upload cleanup skipped because persisted references could not be verified\",\n            )\n        return {\"status\": \"success\", \"files_cleaned\": cleaned_count}\n\n    @router.get(\"/stats\")\n    async def upload_stats(request: Request):\n        \"\"\"Get statistics about uploaded files.\"\"\"\n        require_admin(request)\n        try:\n            return upload_handler.get_upload_stats()\n        except Exception as e:\n            logger.error(f\"Failed to get upload stats: {e}\")\n            raise HTTPException(500, \"Failed to get upload statistics\")\n\n    @router.get(\"/{file_id}\")\n    async def download_file(request: Request, file_id: str, thumb: int = 0):\n        \"\"\"Serve an uploaded file by its ID. `?thumb=1` returns a small cached\n        JPEG thumbnail for images (used by chat attachment previews) so the\n        client isn't downloading the full-resolution photo just to show it tiny.\"\"\"\n        if not upload_handler.validate_upload_id(file_id):\n            raise HTTPException(400, \"Invalid file ID\")\n        import mimetypes as _mt\n        # Look up original filename and owner from uploads.json\n        original_name = file_id\n        # _load_upload_index() tolerates a missing/corrupt uploads.json (it falls\n        # back to the .bak sibling, then to {}), so a truncated DB degrades to\n        # \"no metadata\" instead of a 500 from an unhandled JSONDecodeError.\n        db = upload_handler._load_upload_index()\n        info = next((fi for fi in db.values() if fi.get(\"id\") == file_id), None)\n        if info:\n            original_name = info.get(\"name\", file_id)","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/upload_routes.py#L333-L369","documentation":"Error \"Failed to get upload statistics\" thrown in odysseus-dev/odysseus.","triggerScenarios":"Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.","commonSituations":"See trigger scenarios.","solutions":["Retry; check server logs for the storage error.","Verify the upload storage directory is readable."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}