Repository navigation
fix(proxy): regenerate lazy OpenAPI snapshot and guard it in CI - #38410
mateo-berri merged 4 commits into
Conversation
The committed snapshot behind /openapi.json for unloaded lazy features had drifted on 30 of 31 fragments and never had one for a2a_registration or gemini_agents, so those routes showed as placeholder GET stubs or old docstrings until traffic loaded them. Regenerate the snapshot and schema.d.ts, make the check-ui-api-types job and make check regenerate the snapshot and fail on drift, and make the generator refuse to write a snapshot when any feature fails to import so a broken import cannot silently drop fragments.
Greptile SummaryThe PR regenerates the lazy-route OpenAPI snapshot and generated dashboard API types, then adds local and CI drift checks.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/proxy/_lazy_openapi_snapshot.py | Generates typed, deterministic lazy-route OpenAPI fragments and refuses partial output when feature imports fail. |
| tests/test_litellm/proxy/test_lazy_openapi_snapshot.py | Covers snapshot generation, deterministic serialization, missing features, and import or registration failures. |
| .github/workflows/check-ui-api-types.yml | Regenerates the lazy OpenAPI snapshot and rejects drift before regenerating dashboard types. |
| scripts/pre_commit_lint.sh | Adds the same snapshot regeneration and drift validation to the local check workflow. |
| litellm/proxy/_lazy_openapi_snapshot.json | Refreshes lazy feature fragments and adds previously absent a2a_registration and gemini_agents specifications. |
| ui/litellm-dashboard/src/lib/http/schema.d.ts | Regenerates dashboard API types from the updated proxy OpenAPI specification. |
Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e9f3963. Configure here.
…itellm_regenerate_lazy_openapi_snapshot
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit cd9dcb5. Configure here.
TLDR
Problem this solves:
/openapi.jsonserved stale docs for the 31 lazily loaded route groupsHow it solves it:
_lazy_openapi_snapshot.json(33 fragments) andschema.d.tsfrom itmake checkruns the same regenerate-and-diff locallyUser Flow
Before: a platform engineer wiring their API portal to the gateway's spec gets stale or placeholder docs for routes the proxy has not loaded yet
GET https://litellm-domain/openapi.json/v1/a2a/discoverand/v1beta/agentseach appear as a single GET whose summary is justa2a_registrationorgemini_agents, and/v1beta/agents/{name}plus/v1beta/agents/{name}/versionsare missingGET /policies/listdescription still reads "On a name conflict with a DB policy, only the DB policy is returned" and thePOST /v1/agentsexample body is mis-indentedhttps://litellm-domain/and Swagger shows the same placeholders and old textAfter: the same request returns the current routes and docs for every lazily loaded feature
GET https://litellm-domain/openapi.json/v1/a2a/discovershowsPOST Discover Agent Card,/v1beta/agentsshowsGET List Gemini AgentsandPOST Create Gemini Agent, and/v1beta/agents/{name}plus/v1beta/agents/{name}/versionsare listed with their real operationsGET /policies/listdescription reads the current "On a name conflict with a production DB policy" text and thePOST /v1/agentsexample is indented like the sourcehttps://litellm-domain/renders those same routes and descriptionsRelevant issues
Linear ticket
Resolves LIT-6273
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
Setup shared by both sides: a DB-backed proxy booted with
--num_workers 2from the commit named in each heading,/openapi.jsonfetched as the first request after boot so no lazy feature has been loaded by traffic. Config:Inspection script
inspect.py, fed the raw spec on stdin:Before (f57e4b8)
Lazy routes for a2a_registration and gemini_agents
curl -s http://localhost:20230/openapi.json | python3 inspect.pyDocstring drift on GET /policies/list and POST /v1/agents
Staging merge (cd9dcb5) delta
POST /prompts, which now serves the fixedcreate_promptexample that fix(prompts): reject keyed prompt_data with prompt_id and populate prompt version #38404 shippedSnapshot drift check
uv run python -m litellm.proxy._lazy_openapi_snapshot && git diff --stat -- litellm/proxy/_lazy_openapi_snapshot.jsonwrote 33 feature fragments, then1 file changed, 7514 insertions(+), 956 deletions(-)with no CI job or local check flagging itAfter (cd9dcb5)
Lazy routes for a2a_registration and gemini_agents
curl -s http://localhost:56140/openapi.json | python3 inspect.pyDocstring drift on GET /policies/list and POST /v1/agents
Snapshot drift check
uv run python -m litellm.proxy._lazy_openapi_snapshot && git diff --stat -- litellm/proxy/_lazy_openapi_snapshot.jsonwrote 33 feature fragmentsand an empty diff; three local runs plus one from a CI-equivalentuv sync --frozen --group ci --group proxy-dev --extra google --extra proxy --extra semantic-routerenv on Python 3.12 produced byte-identical filesscripts/pre_commit_lint.shand the workflow are unchanged since): delete thegemini_agentsfragment from the JSON,git addit, runmake checkType
🐛 Bug Fix
🚄 Infrastructure
Caveats (if any)
Medium
mcp_management, cloudzero, vantage, config_overrides fragments still missing from
/openapi.jsonon a DB-backed proxyOpen PRs that change a lazily loaded route now fail the schema.d.ts sync job until they regenerate the snapshot
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
cd9dcb5 passes /live-pr-risk
Note
Low Risk
Infrastructure and OpenAPI snapshot sync only; no changes to request handling, auth, or data paths in the reviewed workflow step.
Overview
Keeps
litellm/proxy/_lazy_openapi_snapshot.jsonaligned with lazily loaded proxy routes so/openapi.jsonand the dashboard types are not stale before those features are imported at runtime.The Check UI API Types workflow now regenerates the snapshot (
python -m litellm.proxy._lazy_openapi_snapshot) after Prisma generate and fails if the committed JSON drifts, with instructions to rerun the module andnpm run gen:api. The same regenerate-and-diff flow is mirrored inmake check(scripts/pre_commit_lint.sh), and the snapshot writer refuses to commit a file when any lazy feature fails to import.Reviewed by Cursor Bugbot for commit cd9dcb5. Bugbot is set up for automated code reviews on this repo. Configure here.