Commit graph

31938 commits

Author SHA1 Message Date
Ishaan Jaff
f236e9ecbb
Update litellm/proxy/policy_engine/policy_resolve_endpoints.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-10 17:50:16 -08:00
Ishaan Jaffer
a9e30a0d39 fix: eliminate duplicate DB queries and fix header delimiter ambiguity
- Fetch teams table once in estimate_attachment_impact and reuse for
  both tag-based and alias-based lookups (was querying teams twice when
  both tag_patterns and team_patterns were provided).
- Convert tag/team filter functions from async DB queries to sync
  filters that operate on pre-fetched data (_filter_keys_by_tags,
  _filter_teams_by_tags).
- Fix comma ambiguity in x-litellm-policy-sources header: use '; '
  as entry delimiter since matched_via values can contain commas.
- Use '+' as the within-value separator in matched_via reason strings
  (e.g. "tag:healthcare+team:health-team") to avoid conflict with
  header delimiters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 17:32:48 -08:00
Ishaan Jaffer
e9ff805c26 fix: address Greptile review feedback on policy resolve endpoints
- Track unnamed keys/teams as separate counts instead of inflating
  affected_keys_count with duplicate "(unnamed key)" placeholders.
  Added unnamed_keys_count and unnamed_teams_count to response.
- Push alias pattern matching to DB via _build_alias_where() which
  converts exact patterns to Prisma "in" and suffix wildcards to
  "startsWith" filters.
- Gate sync_policies_from_db/sync_attachments_from_db behind
  force_sync query param (default false) to avoid 2 DB round-trips
  on every /policies/resolve request.
- Remove worktree-only conftest.py that cleared sys.modules at import
  time — no longer needed since code moved to main repo.
- Rename MAX_ESTIMATE_IMPACT_ROWS → MAX_POLICY_ESTIMATE_IMPACT_ROWS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 17:23:15 -08:00
Ishaan Jaffer
0eeddcc8be fix 2026-02-10 17:08:28 -08:00
Ishaan Jaffer
ff467ac3c1 refactor 2026-02-10 16:47:48 -08:00
Ishaan Jaffer
700be68a38 TestMatchAttribution 2026-02-10 16:45:05 -08:00
Ishaan Jaffer
5bb8f4b92c add_guardrails_from_policy_engine 2026-02-10 16:41:00 -08:00
Ishaan Jaffer
602b81d149 add policy_resolve_router 2026-02-10 16:39:02 -08:00
Ishaan Jaffer
62f9172ecd test fixes 2026-02-10 16:38:07 -08:00
Ishaan Jaffer
4093a23573 TestTagBasedAttachments 2026-02-10 16:37:38 -08:00
Ishaan Jaffer
6f1a8dd84e match based on TAGs 2026-02-10 16:37:09 -08:00
Ishaan Jaffer
7c462cbb0a def _describe_match_reason( 2026-02-10 16:36:42 -08:00
Ishaan Jaffer
850f71135a preview Impact 2026-02-10 16:34:23 -08:00
Ishaan Jaffer
710e132201 types Policy 2026-02-10 16:32:20 -08:00
Ishaan Jaffer
3f5279cdad add_policy_sources_to_metadata + headers 2026-02-10 16:31:16 -08:00
Ishaan Jaffer
9d9f90962b resolvePoliciesCall 2026-02-10 16:29:55 -08:00
Ishaan Jaffer
5a3acb43e4 ui: add policy test 2026-02-10 16:29:10 -08:00
Ishaan Jaffer
1d44cea1ef init schema with TAGS 2026-02-10 16:28:36 -08:00
yuneng-jiang
b70f97e653
Merge pull request #20790 from BerriAI/litellm_ui_inv_user_msg
[Feature] UI - Invite User: Email Integration Alert
2026-02-09 18:04:17 -08:00
Ishaan Jaff
19024e0602
[Feat] MCP Oauth2 Fixes - Add support for MCP M2M Oauth2 support (#20788)
* add has_client_credentials

* MCPOAuth2TokenCache

* init MCP Oauth2 constants

* MCPOAuth2TokenCache

* resolve_mcp_auth

* test fixes

* docs fix

* address greptile review: min TTL, env-configurable constants, tests, docs

- Fix zero-TTL edge case: floor at MCP_OAUTH2_TOKEN_CACHE_MIN_TTL (10s)
- Make all MCP OAuth2 constants env-configurable via os.getenv()
- Move test file to follow 1:1 mapping convention (test_oauth2_token_cache.py)
- Add MCP OAuth doc page (mcp_oauth.md) with M2M and PKCE sections
- Update FAQ in mcp.md to reflect M2M support
- Add E2E test script and config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix mypy lint

* fix oauth2

* remove old files

* docs fix

* address greptile comments

* fix: atomic lock creation + validate JSON response shape

- Use dict.setdefault() for atomic per-server lock creation
- Add isinstance(body, dict) check before accessing token response fields

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: replace asserts with proper guards, wrap HTTP errors with context

- Replace `assert` statements with `if/raise ValueError` (asserts can be
  disabled with python -O in production)
- Wrap `httpx.HTTPStatusError` to provide a clear error message with
  server_id and status code
- Add tests for HTTP error and non-dict JSON response error paths
- Remove unused imports

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 17:35:11 -08:00
michelligabriele
35eb303098
fix(prometheus): sanitize label values to prevent metric scrape failures (#20600)
* fix(prometheus): sanitize label values to prevent metric scrape failures

Unicode characters like U+2028 (Line Separator) in Prometheus label values
break the text exposition format, causing scrapers (e.g. Datadog) to fail
parsing the entire /metrics endpoint. One bad label value causes ALL metrics
to be lost, not just the affected metric.

Add _sanitize_prometheus_label_value() and apply it in prometheus_label_factory()
and all direct .labels() call sites.

* fix(prometheus): handle non-string label values in sanitization

Coerce non-string values (int, bool, float) to str before applying
sanitization, preventing AttributeError on .replace() calls.

* fix(prometheus): run sanitization on coerced non-string values

Non-string values should be coerced to str and then sanitized (not
returned early), so their string representations also get cleaned.

* fix(prometheus): widen type hint to Optional[Any] for label value sanitization
2026-02-09 15:48:59 -08:00
yuneng-jiang
a41a4b41f5 Text changes 2026-02-09 15:20:39 -08:00
yuneng-jiang
145ef7d388 extending timeout for long running tests 2026-02-09 15:02:47 -08:00
yuneng-jiang
cbcbbff604 fixing tests 2026-02-09 14:45:08 -08:00
yuneng-jiang
409d12b7a5 Add alert about email notifications 2026-02-09 14:40:51 -08:00
yuneng-jiang
bb17ca15e9
Merge pull request #20785 from BerriAI/litellm_ui_team_info_refactor
[Refactor] UI - Team Info: Migrate to AntD Tabs + Table
2026-02-09 14:13:22 -08:00
yuneng-jiang
c2536ee82a refactor antd tabs and table 2026-02-09 14:05:05 -08:00
yuneng-jiang
f8660a8ab0
Merge pull request #20780 from BerriAI/litellm_ui_coverage_04
[Refactor] UI - Remove unused files + Add unit tests
2026-02-09 13:02:42 -08:00
Ishaan Jaff
4555ed37c5
fix(callbacks): allow MAX_CALLBACKS override via env var (#20781)
* fix(callbacks): allow MAX_CALLBACKS override via env var (#20778)

* fix(callbacks): allow MAX_CALLBACKS override via env var

- Move MAX_CALLBACKS from logging_callback_manager.py to constants.py
- Add LITELLM_MAX_CALLBACKS env var override (default: 30)
- Add troubleshooting doc explaining the limit and override

Fixes issue where large deployments with 60+ teams using guardrails
would hit the hardcoded MAX_CALLBACKS=30 limit and fail to start.

* docs: add max_callbacks to sidebar navigation

---------

Co-authored-by: shin-bot-litellm <shin-bot-litellm@users.noreply.github.com>

* fix callbacks issue

---------

Co-authored-by: shin-bot-litellm <shin-bot-litellm@berri.ai>
Co-authored-by: shin-bot-litellm <shin-bot-litellm@users.noreply.github.com>
2026-02-09 12:11:32 -08:00
yuneng-jiang
ff5a3acc1c addressing feedback around tests 2026-02-09 12:07:53 -08:00
yuneng-jiang
fb4daad8d4 refactor: remove some unused files and add tests 2026-02-09 11:50:40 -08:00
yuneng-jiang
9bb7f18795
Merge pull request #20773 from BerriAI/litellm_ui_error_code
[Feature] UI - Logs: Show Predefined Error Codes in Filter with User Definable Fallback
2026-02-09 11:42:36 -08:00
yuneng-jiang
a7ed3f240c Show predefined error codes in UI with user adjustable fallback 2026-02-09 11:08:28 -08:00
Ishaan Jaffer
f2ba120c43 docs fix 2026-02-09 10:59:57 -08:00
Ishaan Jaff
9532ad0fab
docs fix (#20768) 2026-02-09 10:03:43 -08:00
Sameer Kankute
136fc698ef
Merge pull request #20601 from Harshit28j/litellm_fix_budget_model_v2
fix conflicts with main- (this PR is from upstream/main)
2026-02-09 20:08:27 +05:30
Sameer Kankute
6b2bcdb870
Merge pull request #20483 from BerriAI/litellm_completion_websearch
[Feat] Chat completion - Add Websearch support using LiteLLM /search (using web search interception hook)
2026-02-09 17:52:52 +05:30
Sameer Kankute
6158e46f00
Merge pull request #20747 from BerriAI/litellm_image_gen_bas_model_fix
Fix: base_model name for body and deplyment name in URL
2026-02-09 17:51:41 +05:30
Sameer Kankute
2d18ae4f9e Fix mypy issues 2026-02-09 17:44:39 +05:30
Sameer Kankute
125e11d36e Fix mypy issues 2026-02-09 17:43:52 +05:30
Sameer Kankute
5693e2c785
Merge pull request #20752 from BerriAI/litellm_fix_cicd_9_feb
Fix: get_supported_anthropic_messages_params
2026-02-09 17:38:39 +05:30
Sameer Kankute
5702cc7e13 Fix: get_supported_anthropic_messages_params 2026-02-09 17:38:03 +05:30
Sameer Kankute
0b5cb47c03 fix: Missing return statement for async streaming 2026-02-09 17:34:48 +05:30
Sameer Kankute
e5f41ba054
Merge pull request #20733 from BerriAI/litellm_v1_messages_claude_4_6
[Feat]Add new claude 4-6 feat for v1/messages
2026-02-09 17:26:40 +05:30
Sameer Kankute
5611974228 Fix : litellm/tests/test_litellm/llms/bedrock/chat/invoke_transformations/test_bedrock_chat_invoke_transformations_anthropic_claude3_transformation.py 2026-02-09 17:18:05 +05:30
Sameer Kankute
ef55d37bf0
Merge branch 'main' into litellm_v1_messages_claude_4_6 2026-02-09 17:14:36 +05:30
Sameer Kankute
30d17c29e4 handle when litellm_parrams might be none 2026-02-09 17:13:39 +05:30
Sameer Kankute
3cf109ed0c
Merge pull request #20745 from BerriAI/litellm_vercel_ai_models
Add new vercel ai anthropic models
2026-02-09 17:07:56 +05:30
Sameer Kankute
23088f86bd Add response schema for vercel ai sonnet 4.5 2026-02-09 17:07:36 +05:30
Sameer Kankute
493eaa6200
Merge pull request #20748 from BerriAI/litellm_anthropic_output_config
Add output_config as supported param
2026-02-09 17:04:08 +05:30