Repository navigation
fix(organization): clear org budget limits when PATCH /organization/update sends null - #39670
Merged
ryan-crabbe-berri merged 3 commits intoSep 4, 2026
Conversation
…pdate sends null A sent null for tpm_limit, rpm_limit, max_budget and the other budget fields was dropped by a 'v is not None' filter, so update_budget was never called and the request returned 200 without changing the budget row. Presence is now read from model_fields_set (merge-patch semantics, matching /v2/organization) and the nested litellm_budget_table payload no longer drops nulls either Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
Greptile SummaryThe PR gives the legacy organization-update endpoint merge-patch semantics for budget fields.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/proxy/management_endpoints/organization_endpoints.py | Uses field presence rather than non-null values to propagate explicit budget clears while preserving omitted fields. |
| tests/test_litellm/proxy/management_endpoints/test_organization_endpoints.py | Adds typed test coverage for top-level and nested null clears and verifies omitted budget fields do not trigger writes. |
Reviews (2): Last reviewed commit: "test(organization): type the legacy upda..." | Re-trigger Greptile
…itellm_fix_org_update_null_budget_limits
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
@greptile re review |
Merged
4 of 6 tasks
yuneng-berri
approved these changes
Sep 4, 2026
ryan-crabbe-berri
merged commit Sep 4, 2026
a502c72
into
litellm_internal_staging
181 of 184 checks passed
ryan-crabbe-berri
deleted the
litellm_fix_org_update_null_budget_limits
branch
September 4, 2026 20:31
3 of 5 tasks
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.
TLDR
Problem this solves:
PATCH /organization/updatewith"tpm_limit": nullreturned 200 but changed nothingrpm_limit,max_budgetand the other budget fields, top level or nested underlitellm_budget_tablePOST /budget/updatedirectlyHow it solves it:
model_fields_set), not byv is not None/budget/update, which already writes nulls throughPATCH /v2/organization/{organization_id}already hasUser Flow
Before: an admin trying to remove an org's TPM limit over the API gets a 200 but the limit stays
{"organization_alias": "my-org", "tpm_limit": 2026, "rpm_limit": 99}and get back anorganization_idand a budget showingtpm_limit: 2026{"organization_id": "<id>", "tpm_limit": null}litellm_budget_table.tpm_limitis still2026After: the same request clears the limit
{"organization_alias": "my-org", "tpm_limit": 2026, "rpm_limit": 99}and get back anorganization_idand a budget showingtpm_limit: 2026{"organization_id": "<id>", "tpm_limit": null}litellm_budget_table.tpm_limitisnull;rpm_limitis still 99 because it was not senttpm_limit: nullRelevant issues
Linear ticket
Resolves LIT-5769
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup: proxy running
litellm/proxy/dev_config.yamlon localhost against local Postgres, master keysk-1234Before (a5b3bc8)
Top-level tpm_limit: null
curl -s -w '\nHTTP %{http_code}\n' -X PATCH http://localhost:4000/organization/update -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d "{\"organization_id\":\"$ORG_ID\",\"tpm_limit\":null}" | jq -c '.litellm_budget_table | {tpm_limit, rpm_limit, max_budget}'{"tpm_limit":2026,"rpm_limit":99,"max_budget":12.5}thenHTTP 200curl -s "http://localhost:4000/organization/info?organization_id=$ORG_ID" -H 'Authorization: Bearer sk-1234' | jq -c '.litellm_budget_table | {tpm_limit, rpm_limit, max_budget}'{"tpm_limit":2026,"rpm_limit":99,"max_budget":12.5}Nested litellm_budget_table.rpm_limit: null
curl -s -X PATCH http://localhost:4000/organization/update -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d "{\"organization_id\":\"$ORG_ID\",\"litellm_budget_table\":{\"rpm_limit\":null}}" | jq -c '.litellm_budget_table | {tpm_limit, rpm_limit, max_budget}'{"tpm_limit":2026,"rpm_limit":99,"max_budget":12.5}After (04a2407, tip fb4cbcc only merges the base branch on top with no code changes)
Top-level tpm_limit: null
curl -s -w '\nHTTP %{http_code}\n' -X PATCH http://localhost:4000/organization/update -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d "{\"organization_id\":\"$ORG_ID\",\"tpm_limit\":null}" | jq -c '.litellm_budget_table | {tpm_limit, rpm_limit, max_budget}'{"tpm_limit":null,"rpm_limit":99,"max_budget":12.5}thenHTTP 200curl -s "http://localhost:4000/organization/info?organization_id=$ORG_ID" -H 'Authorization: Bearer sk-1234' | jq -c '.litellm_budget_table | {tpm_limit, rpm_limit, max_budget}'{"tpm_limit":null,"rpm_limit":99,"max_budget":12.5}Nested litellm_budget_table.rpm_limit: null
curl -s -X PATCH http://localhost:4000/organization/update -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d "{\"organization_id\":\"$ORG_ID\",\"litellm_budget_table\":{\"rpm_limit\":null}}" | jq -c '.litellm_budget_table | {tpm_limit, rpm_limit, max_budget}'{"tpm_limit":null,"rpm_limit":null,"max_budget":12.5}Omitted budget fields are left alone (rename only)
curl -s -X PATCH http://localhost:4000/organization/update -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d "{\"organization_id\":\"$ORG_ID\",\"organization_alias\":\"lit5769-renamed\"}" | jq -c '{organization_alias, budget: (.litellm_budget_table | {tpm_limit, rpm_limit, max_budget})}'{"organization_alias":"lit5769-renamed","budget":{"tpm_limit":null,"rpm_limit":null,"max_budget":12.5}}psql -d litellm -tAc "select tpm_limit, rpm_limit, max_budget from \"LiteLLM_BudgetTable\" where budget_id='$BUDGET_ID'"prints||12.5Type
🐛 Bug Fix
Caveats (if any)
Low
litellm_budget_tablepayloads now also pass nulls through, so a client echoing back a full budget object with null fields will clear them. The Admin UI no longer uses this endpoint (it moved to/v2/organization/{organization_id}), so no UI flow is affectedFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/3bf227d1a7b4452e9291e303a8a3d9c3
Open in Devin Desktop: https://app.devin.ai/desktop/session/3bf227d1a7b4452e9291e303a8a3d9c3?variant=devin