Skip to content

test(auth): freeze prefetch cache clock so the org getter cannot miss on a slow runner - #41278

Draft
cursor[bot] wants to merge 6 commits into
mainfrom
cursor/ci-autofix-automation-4fb9
Draft

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

Conversation

@cursor

@cursor cursor Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

Relevant issues

Backport of #41102 to litellm_internal_staging

Linear ticket

Type

✅ Test

Screenshots / Proof of Fix

All four push runs of the Postgres Tests workflow on litellm_internal_staging since #40834 landed have failed on the same test:

All four fail with the identical:

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

Root cause (quoted from the main fix commit f4e21430c0): 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 expires before get_org_object reads it and the getter falls through to the MagicMock dead_db, whose db.litellm_organizationtable.find_unique(...) returns a non-awaitable MagicMock.

Main has been green on the same workflow since the fix landed (e.g. run https://github.com/BerriAI/litellm/actions/runs/35010237987, push main at 2026-09-15 18:53Z, Postgres Tests succeeded).

This PR is a mechanical backport of the exact test-only diff on main, verified with git diff origin/main -- tests/proxy_behavior/auth/test_auth_object_prefetch.py returning empty after the change.

Caveats

Low

  • Test-only change; no production code path is touched.

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
… on a slow runner

Backport of f4e2143 (originally on main via PR #41102). The org cache
entries written by prefetch_auth_objects carry the 5s DEFAULT_IN_MEMORY_TTL,
so on a slow CI runner the entry expires before get_org_object reads it and
the getter falls through to the MagicMock database, producing a
TypeError: object MagicMock can't be used in 'await' expression at
tests/proxy_behavior/auth/test_auth_object_prefetch.py::test_join_binds_the_membership_to_the_requested_team.

Inject a frozen clock into InMemoryCache so the test asserts the SQL join,
not import or scheduler latency.

Co-authored-by: Krrish Dholakia <krrish-berri-2@users.noreply.github.com>
@CLAassistant

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 sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@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!

This branch has not been deployed

No deployments
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