Skip to content

test(ui): inject the auto-router availability debounce so saves settle deterministically - #42936

Open
devin-ai-integration[bot] wants to merge 3 commits into
mainfrom
litellm_deflake_20260924
Open

devin-ai-integration[bot] wants to merge 3 commits into
mainfrom
litellm_deflake_20260924

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • edit_auto_router_modal.integration.test.tsx flaked on main about 14 times in 24 hours
  • Save button waits on a real 300ms debounce inside a 1000ms waitFor
  • Under CI load (14 forked workers) that window is routinely missed

How it solves it:

  • The availability debounce delay becomes an injected React context, default 300ms
  • renderWithProviders injects 0ms, which resolves the debounce synchronously with no timer
  • No test assertions changed, production default is unchanged

User Flow

Before: a maintainer's unrelated PR goes red on the UI unit tests job for the auto-router edit modal

  1. They push a commit and open https://github.com/BerriAI/litellm/actions, the UI Unit Tests run fails
  2. The log shows expect(element).toBeEnabled() on the modal's Save button with disabled=""
  3. They re-run the job with no code change and it passes

After: the same job is green on the first attempt because the Save gating no longer waits on a real timer

  1. They push a commit and the UI Unit Tests run passes
  2. Opening the auto-router edit modal in the Admin UI behaves exactly as before, the 300ms debounce still applies in production

Flakes covered, by run date

2026-09-23 and 2026-09-24

src/components/edit_auto_router/edit_auto_router_modal.integration.test.tsx > EditAutoRouterModal keyword matching > hydrates the saved threshold and saves an edit to '0' and the '' case, plus the same signature on other cases of the file (classifier vision > hydrates and keeps a stored vision setting through an untouched save reproduced locally)

CI evidence, all UI Unit Tests attempt 1 failures on main interleaved with passing runs at adjacent SHAs of the same job:

The same test also failed on several PR branches in the window (about 23 failing runs total) and passed on re-run. Locally it reproduced once under --sequence.shuffle --maxWorkers=7 and then passed with no edits

Mechanism: wall-clock dependence. useAutoRouterAvailability debounces the serialized router config with a real 300ms setTimeout and the modal keeps Save disabled with "Checking availability" until that timer fires and the availability query settles. Even an untouched save pays the debounce because hydrating the form changes the serialized config after mount. Unloaded, these tests already take about 800ms, so the default 1000ms waitFor ceiling is crossed whenever the CI runner is contended

Fix: the delay is dependency-injected through AutoRouterAvailabilityDebounceContext (default 300ms) and the shared test renderer provides 0ms. At 0ms the hook derives the debounced value directly instead of scheduling a timer: a setTimeout(0) still costs a task hop plus a re-render per config change, and that revision (bd7fef2) still failed the same two tests in CI. The test that asserts Save is blocked while a change is being checked keeps its meaning because that state comes from the pending availability fetch, not from the timer. Mutation check: hardcoding the modal's blocked reason made 56 of 64 cases in the file fail, including the two flaky ones, then the mutation was reverted

A/B under contention (14 forked workers pinned to one CPU with taskset -c 0, the three auto-router integration files, alternating runs): the merge base 04f3ade failed 10 of 10 runs with the exact CI signature, 25 failing cases in total across 11 hydration and save tests; the PR tip 4e9eace passed 10 of 10 runs and kept the modal file green in 3 shuffled runs. Logs live in the automation's evidence directory

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/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
  • 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
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Type

✅ Test

Caveats (if any)

Low

  • Every renderWithProviders tree now sees a 0ms availability debounce, only auto-router components read it
  • Under the same one-CPU shuffle, add_auto_router_tab.integration.test.tsx shows a separate tuning-alert race that never flaked in CI, left for a future run
  • Production behavior is untouched, so there is no end-user before/after to screenshot

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

Link to Devin session: https://app.devin.ai/sessions/1f6fea308eb141e78860c892cd6f6551
Open in Devin Desktop: https://app.devin.ai/desktop/session/1f6fea308eb141e78860c892cd6f6551?variant=devin

…e deterministically

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot requested a review from a team September 24, 2026 10:33
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

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

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

@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable new issue was established.

Summary

The PR injects the auto-router availability debounce delay, retaining the 300ms production default while letting the shared test renderer bypass the timer.

  • The latest changes make the 0ms path use the serialized configuration directly and format the test provider.

Reviews (2) · Last reviewed commit: "fix(ui): resolve the auto-router availab..."

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

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

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri enabled auto-merge (squash) September 24, 2026 12:31

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.

2 participants