{"record":{"id":"2dcbef31fb0b13fc","repo":"odysseus-dev/odysseus","slug":"invalid-file-id","errorCode":null,"errorMessage":"Invalid file ID","messagePattern":"Invalid file ID","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"routes/upload_routes.py","lineNumber":359,"sourceCode":"        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)\n        auth_mgr = getattr(request.app.state, \"auth_manager\", None)\n        auth_configured = bool(auth_mgr and auth_mgr.is_configured)\n        current_user = effective_user(request)\n        file_owner = info.get(\"owner\") if info else None\n        if auth_configured:\n            if not current_user:\n                raise HTTPException(403, \"Access denied\")\n            if file_owner != current_user and not auth_mgr.is_admin(current_user):","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/upload_routes.py#L341-L377","documentation":"Error \"Invalid file ID\" 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":["Use a valid upload file id from an upload response.","Check the id for typos or truncation."],"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-15T17:31:12.345Z"}