* [Docs] Enable local file support
Implemented internal handling for converting file-type documents to the required format for OCR processing, ensuring seamless integration with various providers.
* Refactor OCR file handling and improve security checks
Removed deprecated MIME type mapping and file conversion functions, replacing them with updated implementations. Enhanced security by rejecting 'file' document types in JSON requests, ensuring file uploads are handled via multipart/form-data. Updated tests to reflect these changes and ensure proper functionality.
* Enhance MIME type validation in OCR processing
Added a regular expression check to validate MIME types in the convert_file_document_to_url_document function, raising a ValueError for invalid types. Updated tests to ensure proper error handling for unsupported MIME types.
* Enhance type safety in OCR file handling
Added type casting for the uploaded file in the _parse_multipart_form function to ensure proper handling of UploadFile instances. This change improves type safety and reduces potential runtime errors during file processing.
* Refactor MIME type handling in document uploads
Updated the MIME type extraction logic to strip parameters from the Content-Type header, ensuring only the base type is used. Added tests to verify that MIME parameters are correctly handled and stripped in various scenarios.
* Update OCR documentation for MIME type recommendations and remove unnecessary tips
Clarified the recommended usage of MIME types for raw bytes in document uploads. Simplified the documentation by removing the tip about multipart file uploads from tools like Postman, ensuring a more concise and focused guide.
* Enhance multipart form handling in OCR endpoints
Updated the _parse_multipart_form function to ignore both 'file' and 'document' fields during form parsing, ensuring that the document built from the uploaded file is not overridden. Added a new test to verify that injected document fields do not affect the constructed document, improving security and robustness of the file upload process.
The /v1/messages/count_tokens proxy endpoint was only passing `messages`
to provider token counting APIs, discarding `system` and `tools`. This
caused clients like Claude Code to receive artificially low token counts
(e.g. 10 instead of 531), preventing proper context window management
and leading to context overflow errors.
Pass system and tools through the full chain:
- TokenCountRequest → proxy_server → provider counters → API handlers
- Bedrock: transform tools to toolConfig format, system to text blocks
- Anthropic/Azure AI: pass through directly (same API format)
Fixes#22285 — extra_headers passed to litellm.image_generation() were
silently dropped on the openai/litellm_proxy/openai_compatible_providers
code path. The azure and azure_ai paths already forwarded them correctly.
Extend the null normalization to access_model_names, access_mcp_server_ids,
and access_agent_ids in addition to assigned_team_ids and assigned_key_ids.
Writing null for non-optional list fields causes ValidationError on read.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a client sends null for assigned_team_ids or assigned_key_ids, ensure
the DB receives [] instead of null, preventing null from being stored where
empty list is expected. Extend test to verify the DB call uses [].
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
set(None) raises TypeError when a client sends null for assigned_team_ids or
assigned_key_ids. Add `or []` to handle null safely, consistent with create.
Add test covering this case.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Initialize teams_to_add/teams_to_remove/keys_to_add/keys_to_remove before
the try block in update_access_group for defensive clarity
- In delete_access_group, update teams/keys returned by find_many directly
(data already fetched) and use _sync_remove only for out-of-sync entities
not found by the hasSome query, eliminating N+1 find_unique calls
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Eliminates TOCTOU race where existing record was read outside the
transaction, allowing a concurrent update to make delta computation stale.
Delta is now computed atomically within the same transaction as the write.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>