Skip to content

test(auth): freeze the cache clock in auth prefetch tests - #41252

Closed
cursor[bot] wants to merge 6 commits into
mainfrom
cursor/ci-autofix-automation-966e
Closed

cursor[bot] wants to merge 6 commits into
mainfrom
cursor/ci-autofix-automation-966e

Conversation

@cursor

@cursor cursor Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Postgres Tests / proxy-behavior fails on every push to litellm_internal_staging
  • test_join_binds_the_membership_to_the_requested_team hits a MagicMock instead of the cache

How it solves it:

User Flow

Before: a developer pushing to litellm_internal_staging watches Postgres Tests / proxy-behavior fail on a slow CI runner

  1. Push a commit to litellm_internal_staging
  2. Open https://github.com/BerriAI/litellm/actions and click the Postgres Tests run
  3. proxy-behavior fails with TypeError: object MagicMock can't be used in 'await' expression from test_join_binds_the_membership_to_the_requested_team

After: the same push turns proxy-behavior green

  1. Push a commit to litellm_internal_staging
  2. Open the same Postgres Tests run
  3. All three tests in tests/proxy_behavior/auth/test_auth_object_prefetch.py pass regardless of import latency

Relevant issues

Affected release

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible
  • I have received a Greptile Confidence Score of at least 4/5

Screenshots / Proof of Fix

Before (af6dc1d)

  1. https://github.com/BerriAI/litellm/actions/runs/34906640889/job/104184741143 shows Postgres Tests / proxy-behavior failing
  2. The pytest summary reads FAILED tests/proxy_behavior/auth/test_auth_object_prefetch.py::test_join_binds_the_membership_to_the_requested_team - TypeError: object MagicMock can't be used in 'await' expression
  3. Traceback ends at litellm/proxy/auth/auth_checks.py:3798: in get_org_object, meaning the org getter fell through the cache and awaited a MagicMock

After (a30ab84)

  1. This branch cherry-picks db79226 from main, which fixed the same failure there
  2. The three tests in tests/proxy_behavior/auth/test_auth_object_prefetch.py now build their UserApiKeyCache with InMemoryCache(clock=lambda: 1_000_000.0), so the 5s org TTL cannot expire mid-test
  3. Postgres Tests / proxy-behavior on this PR's tip will run all three prefetch tests to green

Type

✅ Test

Caveats (if any)

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
Open in Web View Automation 

milan-berri and others added 6 commits August 21, 2026 02:41
…nd Model Hub UI

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

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

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
feat(model_hub): surface model_info.description in Model Hub
…_on_failed_read

fix(health): skip background health check DB writes when the latest-row read fails
The org cache entries written by prefetch_auth_objects carry the 5s
DEFAULT_IN_MEMORY_TTL. The first @log_db_metrics getter lazily imports
litellm.proxy.proxy_server, which on a cold CI runner can take longer
than 5s, so the org entry expired before get_org_object read it and the
getter fell through to the MagicMock database. Inject a frozen clock
into InMemoryCache so the test asserts the join, not import latency.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit db79226)
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@devin-ai-integration
devin-ai-integration Bot changed the base branch from litellm_internal_staging to main September 23, 2026 14:34
@CLAassistant

CLAassistant commented Oct 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 4 committers have signed the CLA.

✅ ryan-crabbe-berri
✅ milan-berri
✅ mateo-berri
❌ yassin-berriai
You have signed the CLA already but the status is still pending? Let us recheck it.

@mateo-berri

Copy link
Copy Markdown
Contributor

Main already has the frozen cache clock for the prefetch tests from #40996, and the other commits here merged already. Reopen if something is missing

@mateo-berri mateo-berri closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants