{"record":{"id":"4f2a3f9f444c5275","repo":"BerriAI/litellm","slug":"both-expires-after-anchor-and-expires-after-secon","errorCode":null,"errorMessage":"Both expires_after[anchor] and expires_after[seconds] must be provided if expires_after is specified","messagePattern":"Both expires_after\\[anchor\\] and expires_after\\[seconds\\] must be provided if expires_after is specified","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/openai_files_endpoints/files_endpoints.py","lineNumber":394,"sourceCode":"        data = {}\n\n        # Parse expires_after if provided\n        expires_after: FileExpiresAfter | None = None\n        form_data_raw: Final = await request.form()\n        form_data_dict: Final[dict[str, Any]] = dict(form_data_raw)\n        extracted_litellm_metadata: Final[dict[str, Any] | None] = extract_nested_form_metadata(\n            form_data=form_data_dict, prefix=\"litellm_metadata[\"\n        )\n        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):","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/openai_files_endpoints/files_endpoints.py#L376-L412","documentation":"HTTPException(400) on file upload: the expires_after field was partially supplied — only one of expires_after[anchor] or expires_after[seconds] is present. Both are required together to define the expiry policy, so the incomplete pair is rejected.","triggerScenarios":"Thrown at litellm/proxy/openai_files_endpoints/files_endpoints.py:394 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide both expires_after[anchor] and expires_after[seconds], or omit expires_after entirely."],"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-14T00:17:10.932Z"}