{"record":{"id":"be35e62e7c6ab2fe","repo":"BerriAI/litellm","slug":"file-id-must-be-a-scheme-uri","errorCode":null,"errorMessage":"file_id must be a {scheme} URI","messagePattern":"file_id must be a (.+?) URI","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/cloud_storage_security.py","lineNumber":143,"sourceCode":"            value = cast(Mapping[str, Any], trusted_model_credentials).get(\"allow_legacy_cloud_file_ids\")\n\n    if isinstance(value, bool):\n        return value\n    if isinstance(value, str):\n        return value.strip().lower() in {\"1\", \"true\", \"yes\", \"on\"}\n    return False\n\n\ndef validate_managed_cloud_file_id(\n    file_id: str,\n    scheme: str,\n    configured_bucket_name: str,\n    allowed_object_prefixes: Sequence[str],\n    allow_legacy_cloud_file_ids: bool = False,\n) -> tuple[str, str]:\n    decoded_file_id: Final = unquote(file_id)\n    if not decoded_file_id.startswith(scheme):\n        raise ValueError(f\"file_id must be a {scheme} URI\")\n\n    full_path: Final = decoded_file_id[len(scheme) :]\n    if \"/\" not in full_path:\n        raise ValueError(\"file_id must include a cloud storage object name\")\n\n    bucket_name, object_name = full_path.split(\"/\", 1)\n    configured_bucket, configured_prefix = split_configured_cloud_bucket_name(configured_bucket_name)\n    if bucket_name != configured_bucket:\n        raise ValueError(\"file_id bucket does not match the configured storage bucket\")\n\n    _validate_cloud_object_path(object_name)\n    allowed_prefixes = tuple(allowed_object_prefixes)\n    if configured_prefix:\n        allowed_prefixes = tuple(f\"{configured_prefix.rstrip('/')}/{prefix}\" for prefix in allowed_prefixes)\n\n    if object_name.startswith(allowed_prefixes):\n        return bucket_name, object_name\n","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/cloud_storage_security.py#L125-L161","documentation":"Guard in validate_managed_cloud_file_id: after URL-decoding, the file_id does not start with the expected scheme prefix (e.g. 's3://'), so it is not a managed cloud file URI of the configured storage type.","triggerScenarios":"Thrown at litellm/litellm_core_utils/cloud_storage_security.py:143 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a file_id URI with the expected scheme (e.g. gs:// or s3:// as configured).","Check the file_id format returned by the files API and pass it unchanged."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}