BerriAI/litellm · error · Exception
LiteLLM Managed {accessor_key} with id={retrieve_object_id}
Error message
LiteLLM Managed {accessor_key} with id={retrieve_object_id} is invalid - does not contain encoded model_id. What it means
After access checks pass for a managed batch/object id, the hook decodes the unified id to extract the encoded model_id via get_model_id_from_unified_batch_id. If the base64 payload does not contain the expected model_id segment (corrupt, truncated, or hand-crafted id), a plain Exception is raised stating the managed object is invalid. This is a data-integrity failure of the unified id, not an auth failure.
Source
Thrown at enterprise/litellm_enterprise/proxy/hooks/managed_files.py:693
if accessor_key:
retrieve_object_id = cast(Optional[str], data.get(accessor_key))
potential_llm_object_id = (
_is_base64_encoded_unified_file_id(retrieve_object_id) if retrieve_object_id else False
)
if potential_llm_object_id and retrieve_object_id:
## VALIDATE USER HAS ACCESS TO THE OBJECT ##
if not await self.can_user_call_unified_object_id(retrieve_object_id, user_api_key_dict):
raise HTTPException(
status_code=403,
detail=f"User {user_api_key_dict.user_id} does not have access to the object {retrieve_object_id}",
)
## for managed batch id - get the model id
potential_model_id = get_model_id_from_unified_batch_id(potential_llm_object_id)
if potential_model_id is None:
raise Exception(
f"LiteLLM Managed {accessor_key} with id={retrieve_object_id} is invalid - does not contain encoded model_id."
)
data["model"] = potential_model_id
data[accessor_key] = get_batch_id_from_unified_batch_id(potential_llm_object_id)
elif call_type == CallTypes.acreate_fine_tuning_job.value:
input_file_id = cast(Optional[str], data.get("training_file"))
if input_file_id:
model_file_id_mapping = await self.get_model_file_id_mapping(
[input_file_id], user_api_key_dict.parent_otel_span
)
return data
async def async_filter_deployments(
self,
model: str,
healthy_deployments: List,
messages: Optional[List[AllMessageValues]],View on GitHub (pinned to 6c2dcb801b)
Solutions
- Re-fetch the id from the creation response or /v1/batches list instead of copying it from logs or external storage
- Ensure ids round-trip byte-for-byte (no trimming of base64 padding, no URL-unescaping twice)
- If ids were created by an older proxy version, re-create the batch after upgrading so the id carries the current encoding
- Check for middleware/gateway code that rewrites or truncates long header/query values containing the id
Example fix
# before: id copied from truncated log line
await client.batches.retrieve("ZmlsZSxsbG1fbW9kZWxfaWQ" ) # missing segments
# after: use the id exactly as returned
job = await client.batches.create(...)
await client.batches.retrieve(job.id) Defensive patterns
Strategy: validation
Validate before calling
import base64
def unified_id_has_model_segment(unified_id: str) -> bool:
try:
decoded = base64.urlsafe_b64encode(unified_id.encode()).decode() if False else unified_id
# ids arrive base64-encoded; validate round-trip and marker presence
raw = base64.urlsafe_b64decode(unified_id + "=" * (-len(unified_id) % 4)).decode()
return "llm_model_id," in raw or "model_id" in raw
except Exception:
return False
assert unified_id_has_model_segment(batch_id), "corrupt unified id; refetch it" Type guard
def is_wellformed_unified_batch_id(bid: str) -> bool:
import base64
try:
pad = bid + "=" * (-len(bid) % 4)
raw = base64.urlsafe_b64decode(pad).decode()
return "model_id" in raw and ";" in raw
except Exception:
return False Try / catch
try:
await client.batches.retrieve(batch_id)
except Exception as e:
if "does not contain encoded model_id" in str(e):
# corrupt id: refetch from creation response, do not retry same id
raise ValueError(f"corrupt unified id {batch_id}") from e
raise Prevention
- Treat unified ids as opaque; never truncate, re-encode, or transcribe them manually
- Store ids in columns sized for full base64 strings
- After proxy upgrades, recreate batches whose ids predate the current format
When it happens
Trigger: Passing a partially-copied or truncated base64 batch id (URL clipping, manual transcription); a unified id minted by an older proxy version with a different encoding scheme; client code that re-encodes or mangles ids between submit and retrieve.
Common situations: Ids stored in text columns that silently truncate; logging pipelines that strip '=' padding from base64; upgrading LiteLLM enterprise versions where the unified-id format changed; hand-modified ids in tests.
Related errors
- Unified id does not contain {marker!r}: {file_id[:80]!r}
- LiteLLM Managed File object with id={file_id} has no file_ob
- LiteLLM Managed File object with id={file_id} not found
- Failed to retrieve file {file_id} from provider: {str(e)}
- LiteLLM Managed File object with id={file_id} not found. Che
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/649af98863d81430.
Report an issue: GitHub.