Skip to content

fix(spend): read budget windows from the auth cache under the auth objects key family - #53287

Merged
mateo-berri merged 1 commit into
mainfrom
litellm_declare_rust_spend_counter_key_family
Nov 21, 2026
Merged

mateo-berri merged 1 commit into
mainfrom
litellm_declare_rust_spend_counter_key_family

Conversation

@mateo-berri

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

Every pull request's required unit check has been failing since the Rust spend counter step landed, because one cache read in it was not labelled the way the repo's rule asks. This labels that read so the check passes again and the read shows up under its proper name in traces

Details

Link to Devin session: https://app.devin.ai/sessions/3242d590986444e499b3a5b6958207b4
Open in Devin Desktop: https://app.devin.ai/desktop/session/3242d590986444e499b3a5b6958207b4?variant=devin
Requested by: @mateo-berri

TLDR

Problem this solves:

  • unit passed is red on main and on every PR
  • One auth cache read in the spend counter step has no key family

How it solves it:

  • Runs that read under the auth_objects key family
  • Adds a test that the read runs under it

User Flow

Before: a contributor's pull request cannot merge, because a required check fails on code they did not touch

  1. They open a pull request against main at https://github.com/BerriAI/litellm/pulls
  2. The root unit job fails on test_every_redis_producer_declares_a_key_family, naming litellm/proxy/spend_tracking/rust_spend_counters.py
  3. The required unit passed check turns red, so the merge button stays blocked

After: the same pull request gets a green unit check once it has this change

  1. They open a pull request against main at https://github.com/BerriAI/litellm/pulls
  2. The root unit job passes test_every_redis_producer_declares_a_key_family
  3. The required unit passed check no longer fails on that test

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<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
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

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

E2E exception at 13743cf. The change is one decorator, @with_service_target(AUTH_OBJECTS_TARGET), on the host callback that reads budget windows from the auth cache, the same label budget_reservation.py already puts on its auth cache reads. No request, response or stored value changes, so focused tests are the proof and no live proxy run was made

Main fails the check at 0ab513b, the merge base

$ uv run --no-sync pytest tests/unit/test_internal_context.py::test_every_redis_producer_declares_a_key_family -q
E         Left contains one more item: 'litellm/proxy/spend_tracking/rust_spend_counters.py'
1 failed in 3.40s

It passes at 13743cf, together with the new test and the rest of both files

$ uv run --no-sync pytest tests/unit/proxy/spend_tracking/test_rust_spend_counters.py tests/unit/test_internal_context.py -q
16 passed in 32.66s

With the decorator taken out again, both tests go red, so the new test catches the label going missing

$ uv run --no-sync pytest tests/unit/proxy/spend_tracking/test_rust_spend_counters.py tests/unit/test_internal_context.py -q
E       AssertionError: assert [None] == ['auth_objects']
E       AssertionError: assert ('litellm/pro...counters.py',) == ()
E         Left contains one more item: 'litellm/proxy/spend_tracking/rust_spend_counters.py'
FAILED tests/unit/proxy/spend_tracking/test_rust_spend_counters.py::test_budget_windows_read_the_auth_cache_under_the_auth_objects_target
FAILED tests/unit/test_internal_context.py::test_every_redis_producer_declares_a_key_family
2 failed, 14 passed in 32.18s

make check passes every gate on this diff except the dashboard API type sync. That one is stale on main from #53214, which added reject_unregistered_guardrails without regenerating schema.d.ts, and this PR leaves it alone

Type

🐛 Bug Fix
✅ Test

Caveats (if any)

Low

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

…jects key family

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@veria-ai

veria-ai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri mateo-berri added the autoapprove This PR may be autoapproved by greptile. The author thinks that it does not need human review. label Nov 21, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This change appears safe to merge.

Summary

Labels the budget-window auth-cache read with AUTH_OBJECTS_TARGET.

  • Budget-window cache reads now use the auth objects target.

Reviews (1) · Last reviewed commit: "fix(spend): read budget windows from the..." · Reviewed by Greptile

@mateo-berri
mateo-berri merged commit b0366b6 into main Nov 21, 2026
50 checks passed
@mateo-berri
mateo-berri deleted the litellm_declare_rust_spend_counter_key_family branch November 21, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoapprove This PR may be autoapproved by greptile. The author thinks that it does not need human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant