{"record":{"id":"128954de9a3dca00","repo":"BerriAI/litellm","slug":"expires-after-anchor-must-be-a-string-not-a-file","errorCode":null,"errorMessage":"expires_after[anchor] must be a string, not a file upload","messagePattern":"expires_after\\[anchor\\] must be a string, not a file upload","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/openai_files_endpoints/files_endpoints.py","lineNumber":403,"sourceCode":"        expires_after_anchor: Final = form_data_raw.get(\"expires_after[anchor]\")\n        expires_after_seconds_str: Final = form_data_raw.get(\"expires_after[seconds]\")\n\n        # Add litellm_metadata to data if provided (from form field)\n        if extracted_litellm_metadata is not None:\n            data[\"litellm_metadata\"] = extracted_litellm_metadata\n\n        if expires_after_anchor is not None or expires_after_seconds_str is not None:\n            if expires_after_anchor is None or expires_after_seconds_str is None:\n                raise HTTPException(\n                    status_code=400,\n                    detail={\n                        \"error\": \"Both expires_after[anchor] and expires_after[seconds] must be provided if expires_after is specified\",\n                    },\n                )\n\n            # Validate expires_after[anchor] is a string (not UploadFile)\n            if isinstance(expires_after_anchor, UploadFile):\n                raise HTTPException(\n                    status_code=400,\n                    detail={\n                        \"error\": \"expires_after[anchor] must be a string, not a file upload\",\n                    },\n                )\n\n            # Validate expires_after[seconds] is a string (not UploadFile)\n            # Use positive isinstance check for proper type narrowing (matches codebase pattern)\n            if not isinstance(expires_after_seconds_str, str):\n                raise HTTPException(\n                    status_code=400,\n                    detail={\n                        \"error\": \"expires_after[seconds] must be a string, not a file upload\",\n                    },\n                )\n            # After this check, mypy knows expires_after_seconds_str is str\n            expires_after_seconds_str_validated: Final[str] = expires_after_seconds_str\n","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/openai_files_endpoints/files_endpoints.py#L385-L421","documentation":"HTTPException(400) on file upload: expires_after[anchor] was submitted as a file upload part instead of a string form value (client misused multipart, attaching a file where a scalar was expected). The field must be a plain text form entry.","triggerScenarios":"Thrown at litellm/proxy/openai_files_endpoints/files_endpoints.py:403 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send expires_after[anchor] as a string form field, not a file upload."],"exampleFix":null,"handlingStrategy":"type-guard","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-14T05:17:10.506Z"}