{"record":{"id":"ccd00809e21001a4","repo":"BerriAI/litellm","slug":"litellm-managed-file-object-with-id-file-id-not","errorCode":null,"errorMessage":"LiteLLM Managed File object with id={file_id} not found","messagePattern":"LiteLLM Managed File object with id=(.+?) not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"enterprise/litellm_enterprise/proxy/hooks/managed_files.py","lineNumber":372,"sourceCode":"        )\n\n        if result:\n            return LiteLLM_ManagedFileTable.model_validate(result)\n\n        ## CHECK DB\n        db_object = await _managed_file_table(self.prisma_client).find_first(where={\"unified_file_id\": file_id})\n\n        if db_object:\n            return LiteLLM_ManagedFileTable.model_validate(db_object.model_dump())\n        return None\n\n    async def delete_unified_file_id(\n        self, file_id: str, litellm_parent_otel_span: Optional[Span] = None\n    ) -> OpenAIFileObject:\n        ## get old value\n        initial_value = await _managed_file_table(self.prisma_client).find_first(where={\"unified_file_id\": file_id})\n        if initial_value is None:\n            raise Exception(f\"LiteLLM Managed File object with id={file_id} not found\")\n        ## delete old value\n        await self.internal_usage_cache.async_set_cache(\n            key=file_id,\n            value=None,\n            litellm_parent_otel_span=litellm_parent_otel_span,\n        )\n        await _managed_file_table(self.prisma_client).delete(where={\"unified_file_id\": file_id})\n        return initial_value.file_object\n\n    async def can_user_call_unified_file_id(self, unified_file_id: str, user_api_key_dict: UserAPIKeyAuth) -> bool:\n        managed_file = await _managed_file_table(self.prisma_client).find_first(\n            where={\"unified_file_id\": unified_file_id}\n        )\n\n        if managed_file:\n            return can_access_resource(\n                user_api_key_dict=user_api_key_dict,\n                created_by=managed_file.created_by,","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/enterprise/litellm_enterprise/proxy/hooks/managed_files.py#L354-L390","documentation":"Raised as a plain Exception (500 at the HTTP layer) by ManagedFilesHook.delete_unified_file_id when no row matches the given unified_file_id in the managed file table. The delete path first fetches the row to return its file_object payload; if the find_first returns None - id typo'd, already deleted, or never created through the managed-files API - it fails with this message instead of deleting silently.","triggerScenarios":"Calling the managed files delete endpoint twice (second call finds nothing); deleting a unified file id from a different proxy/database; passing the raw provider file id instead of the base64-encoded unified id; the row was removed by a concurrent request or team member.","commonSituations":"Retry logic in client code re-sends a delete after a timeout even though the first delete succeeded; id confusion between provider file ids (file-abc123) and unified ids (base64 blob); environment mismatch between where the file was uploaded and where deletion is attempted.","solutions":["List managed files for the user first and delete using the exact unified_file_id from the listing","Treat a repeated delete as idempotent success if your workflow allows it (catch the 'not found' message)","Confirm you are on the same proxy/database where the file was created","Ensure you pass the unified (base64-encoded) id returned at creation time, not the provider-side file id"],"exampleFix":"# before\nawait managed_files_hook.delete_unified_file_id(file_id)  # Exception if already gone\n# after\nif await managed_files_hook.get_managed_file(file_id) is not None:\n    await managed_files_hook.delete_unified_file_id(file_id)","handlingStrategy":"validation","validationCode":"# Idempotent delete: only call delete when the row exists\nexisting = await _managed_file_table(prisma).find_first(where={\"unified_file_id\": file_id})\nif existing is None:\n    return existing  # nothing to do (or raise your own NotFound)","typeGuard":null,"tryCatchPattern":"try:\n    obj = await hook.delete_unified_file_id(file_id)\nexcept Exception as e:\n    if \"not found\" in str(e):\n        return  # treat repeated delete as success\n    raise","preventionTips":["Make delete flows idempotent by checking existence first","Always store and reuse the unified_file_id returned at creation","Guard retry logic against non-idempotent deletes with existence checks"],"tags":["litellm","managed-files","not-found","delete","enterprise"],"backgroundTag":"resource-not-found","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}