Repository navigation
fix(proxy): stop key creation with per-model limits in an organization from returning 500 - #53447
Merged
mateo-berri merged 1 commit intoNov 21, 2026
Conversation
mateo-berri
approved these changes
Nov 21, 2026
Contributor
mateo-berri
enabled auto-merge (squash)
November 21, 2026 21:56
Key generation moves model_rpm_limit and model_tpm_limit into metadata and deletes the request attributes before the organization limit check runs, so reading them directly raised AttributeError and /key/generate returned 500 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration
Bot
force-pushed
the
litellm_flakeheal_20261121_test_check_org_key_limits_model_specific
branch
from
November 21, 2026 21:59
3570ed1 to
0e3b2d2
Compare
mateo-berri
deleted the
litellm_flakeheal_20261121_test_check_org_key_limits_model_specific
branch
November 21, 2026 22:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handwritten 1-3 sentence description
Creating a key inside an organization with per-model rate limits has been failing with a 500 error instead of creating the key or saying the organization limit is exceeded. This makes the organization limit check read those limits from where key creation has already moved them, so the request succeeds or returns the proper 400 again
Details
Link to Devin session: https://app.devin.ai/sessions/3fae0adaf7dd4860a54336dede4a6de5
Open in Devin Desktop: https://app.devin.ai/desktop/session/3fae0adaf7dd4860a54336dede4a6de5?variant=devin
Requested by: @mateo-berri
TLDR
Problem this solves:
/key/generatewith an organization andmodel_rpm_limitormodel_tpm_limitreturns 500How it solves it:
CI evidence
integrationruns on main, newest Job (integration management)'GenerateKeyRequest' object has no attribute 'model_rpm_limit'returned as a 500 fromPOST /key/generatemodel_rpm_limitandmodel_tpm_limitintometadataand deletes the attributes from the request object before the organization check runs. refactor(typing): clear 1146 basedpyright Any errors across 365 files #52768 changed_check_key_model_specific_limitsfromgetattr(data, ..., None)todata.model_rpm_limit, which raises once the attribute is goneattribute_or_none, so the existing metadata fallback appliesPre-Submission checklist
Screenshots / Proof of Fix
At 3570ed154b16256fa4cbcdec05a1f9624d511468
tests/integration/run.py management tests/integration/management/test_key_budget_limits.py::test_check_org_key_limits_model_specific: origin/main product code 4 failed with the 500 above, with the fix 4 passedtest_check_org_key_model_specific_limits_reads_limits_already_moved_into_metadata(rpm and tpm),-n 0 --reruns 0: 2 failed on origin/main product code with the same AttributeError, 2 passed with the fix, five runstests/unit/proxy/management_endpoints/test_key_management_endpoints.py: 1010 passedruff checkandruff format --checkon the product file,test_quality_gate.py --base origin/main: passed. basedpyright on the product file: 466 errors before and afterNot proven in CI before merge: a
workflow_dispatchof theintegrationworkflow on this branch (run) was rejected by theintegration-licenseenvironment's branch rules before any step ran, so the integration proof above is local only and the next scheduled main run after merge is the first CI run of itType
🐛 Bug Fix
Final Attestation