{"record":{"id":"653f662f28726122","repo":"BerriAI/litellm","slug":"unified-id-does-not-contain-marker-r-file-id","errorCode":null,"errorMessage":"Unified id does not contain {marker!r}: {file_id[:80]!r}","messagePattern":"Unified id does not contain (.+?): (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"enterprise/litellm_enterprise/proxy/hooks/managed_files.py","lineNumber":1139,"sourceCode":"\n    def get_unified_output_file_id(self, output_file_id: str, model_id: str, model_name: Optional[str]) -> str:\n        deterministic_uuid: Final = uuid5(uuid5(NAMESPACE_URL, model_id), output_file_id)\n        unified_output_file_id = SpecialEnums.LITELLM_MANAGED_FILE_COMPLETE_STR.value.format(\n            \"application/json\",\n            str(deterministic_uuid),\n            model_name or \"\",\n            output_file_id,\n            model_id,\n        )\n        return base64.urlsafe_b64encode(unified_output_file_id.encode()).decode().rstrip(\"=\")\n\n    def get_model_id_from_unified_file_id(self, file_id: str) -> str:\n        return file_id.split(\"llm_output_file_model_id,\")[1].split(\";\")[0]\n\n    def get_output_file_id_from_unified_file_id(self, file_id: str) -> str:\n        marker = \"llm_output_file_id,\"\n        if marker not in file_id:\n            raise ValueError(f\"Unified id does not contain {marker!r}: {file_id[:80]!r}\")\n        return file_id.split(marker, 1)[1].split(\";\")[0]\n\n    async def async_post_call_success_hook(\n        self, data: Dict, user_api_key_dict: UserAPIKeyAuth, response: LLMResponseTypes\n    ) -> LLMResponseTypes:\n        if isinstance(response, LiteLLMBatch):\n            ## Check if unified_file_id is in the response\n            unified_file_id = response._hidden_params.get(\"unified_file_id\")  # managed file id\n            unified_batch_id = response._hidden_params.get(\"unified_batch_id\")  # managed batch id\n            model_id = cast(Optional[str], response._hidden_params.get(\"model_id\"))\n            model_name = cast(Optional[str], response._hidden_params.get(\"model_name\"))\n\n            resolved_model_name = resolve_managed_output_file_model_name(\n                unified_input_file_id=unified_file_id if isinstance(unified_file_id, str) else response.input_file_id,\n                fallback_model_name=model_name,\n            )\n            original_response_id = response.id\n","sourceCodeStart":1121,"sourceCodeEnd":1157,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/litellm_enterprise/proxy/hooks/managed_files.py#L1121-L1157","documentation":"get_output_file_id_from_unified_file_id parses the internal unified file id format, which embeds segments like 'llm_output_file_id,<id>;'. If that marker is absent — corrupt, truncated, or a foreign/unmanaged id that happened to decode — a ValueError is raised showing the first 80 chars for diagnosis. The id was already accepted as base64 unified id, so this signals format corruption rather than a wrong id type.","triggerScenarios":"A base64 string that decodes but lacks the output-file segment (batch output file ids from an older format or hand-assembled); ids truncated by storage columns or URL handling; decoding a unified batch id with the file-id parser.","commonSituations":"Schema migrations that shortened id columns; middleware trimming long ids; mixing id types (batch id vs output file id) in client code after API changes.","solutions":["Use the output file id exactly as returned in the batch completion payload, not reconstructed or stored copies","Verify stored id columns/properties can hold the full base64 string without truncation","Confirm you are passing an output-file unified id (contains llm_output_file_id) and not a batch or input-file id","Recreate the batch if its ids predate the current unified-id format"],"exampleFix":"# before\nfile_id = batch_response.id  # batch id, wrong parser path\n\n# after\nfile_id = batch_response.output_file_id  # correct output-file unified id","handlingStrategy":"type-guard","validationCode":"OUTPUT_MARKER = \"llm_output_file_id,\"\n\ndef is_output_file_unified_id(fid: str) -> bool:\n    import base64\n    try:\n        raw = base64.urlsafe_b64decode(fid + \"=\" * (-len(fid) % 4)).decode()\n        return OUTPUT_MARKER in raw\n    except Exception:\n        return False\n\nassert is_output_file_unified_id(fid), \"not an output-file unified id\"","typeGuard":"def is_output_file_unified_id(file_id: str) -> bool:\n    import base64\n    try:\n        raw = base64.urlsafe_b64decode(file_id + \"=\" * (-len(file_id) % 4)).decode()\n        return \"llm_output_file_id,\" in raw\n    except Exception:\n        return False","tryCatchPattern":"try:\n    get_output_file_id_from_unified_file_id(fid)\nexcept ValueError as e:\n    # id lacks the output-file segment; refetch the correct id from the batch object\n    raise TypeError(f\"{fid} is not an output-file unified id\") from e","preventionTips":["Use batch.output_file_id (which embeds the marker) rather than batch.id","Never store ids in truncated columns or trim base64 padding","Unit-test id round-trips through your persistence layer"],"tags":["files","batch","unified-id","data-corruption"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}