Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR makes two changes: (1) replaces
Confidence Score: 2/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/management_endpoints/key_management_endpoints.py | Replaces prisma.Json() with safe_dumps() in _rotate_master_key, changing type from dict wrapper to JSON string — breaks existing test test_rotate_master_key_model_data_valid_for_prisma and may cause runtime issues with create_many(). |
| tests/test_litellm/proxy/auth/test_object_permission_loading.py | Adds necessary mocks for proxy_logging_obj to fix test failures caused by the log_db_metrics decorator importing and calling service hooks at runtime. The mocking approach is correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[_rotate_master_key] --> B[Fetch models from DB]
B --> C[Decrypt model list]
C --> D[Re-encrypt with new key via _add_model_to_db]
D --> E[model_dump with exclude_none]
E --> F{"Serialize litellm_params & model_info"}
F -->|Before PR| G["prisma.Json(dict) — dict wrapper"]
F -->|After PR| H["safe_dumps(dict) — JSON string"]
G --> I[create_many in transaction]
H --> I
I --> J[Delete old models + Insert new models]
style G fill:#90EE90
style H fill:#FFB6C1
Last reviewed commit: 610bf00
| _dumped["litellm_params"] = safe_dumps(_dumped["litellm_params"]) | ||
| _dumped["model_info"] = safe_dumps(_dumped["model_info"]) |
There was a problem hiding this comment.
Breaking existing test and likely runtime behavior
Replacing prisma.Json(...) with safe_dumps(...) changes the type from a prisma.Json wrapper (which wraps a Python dict) to a JSON string. The existing test test_rotate_master_key_model_data_valid_for_prisma in tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py at lines 5716-5724 explicitly asserts that these fields must be prisma.Json instances, not JSON strings:
assert isinstance(model_data["litellm_params"], prisma.Json), (
f"litellm_params should be prisma.Json for create_many(), got {type(model_data['litellm_params'])}"
)This change will cause that test to fail. Additionally, Prisma's create_many() for Json fields may not accept raw JSON strings the same way create() does — the original code used prisma.Json() specifically for create_many() compatibility.
If the intent is to remove the prisma import dependency here, the existing test also needs to be updated, and you should verify that create_many() actually accepts JSON strings for Json fields (or use json.loads(safe_dumps(...)) to get back a dict).
Context Used: Rule from dashboard - What: Ensure that any PR claiming to fix an issue includes evidence that the issue is resolved, such... (source)
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test
Changes