Repository navigation
fix(proxy): point the startup schema drift check at the packaged schema.prisma - #52435
Conversation
|
[AI] @greptileai review Generated by Claude Code |
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
[Low impact] The change affects the proxy’s startup schema-drift diagnostic. Satisfy the repository’s typing and in-process test requirements before merging. Findings
|
| unrelated_dir.mkdir() | ||
| monkeypatch.chdir(unrelated_dir) | ||
|
|
||
| check_prisma_schema_diff_helper("postgresql://u:p@localhost:9/x") |
There was a problem hiding this comment.
Unit test starts a subprocess
tests/unit/AGENTS.md bans subprocesses here. This test launches the fake CLI through run_prisma. Move it outside the unit suite.
Context Used: AGENTS.md (source)
There was a problem hiding this comment.
[AI] Fixed in 48f0319. The new test no longer uses fake_prisma_cli. It swaps run_prisma for an in-process recorder and checks the argv it gets, so no process starts. The neighbouring timeout test still runs the fake CLI, as it does on main, since killing the process tree is what it tests. Moving that one is outside this PR.
Generated by Claude Code
| [call] = fake_prisma_cli.calls | ||
| assert call[:5] == ["migrate", "diff", "--from-url", "postgresql://u:p@localhost:9/x", "--to-schema-datamodel"] |
There was a problem hiding this comment.
SQL output loses test coverage The shortened assertion stops checking
--script. Removing that flag would silently break SQL extraction. Keep asserting it alongside the path.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
[AI] Fixed in 48f0319. The timeout test asserts call[6:] == ["--script"] again next to the first five args, and the new path test checks --script is still last.
Generated by Claude Code
Merging this PR will not alter performance1 warning
Comparing Footnotes |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
522c589 to
f719cf9
Compare
f719cf9 to
48f0319
Compare
Handwritten 1-3 sentence description
[insert handwritten description here]
Details
TLDR
Problem this solves:
./schema.prisma, which moved underlitellm/How it solves it:
schema.prismashipped inlitellm/proxy/User Flow
Before: an admin who disables schema updates is never told the database is behind the proxy's schema
DISABLE_SCHEMA_UPDATE=true(ordisable_prisma_schema_update: true) against a database missing tablesFailed to generate migration diff ... Error trying to read Prisma schema fileprisma schema out of sync with dbwarning appears, so the drift goes unnoticedAfter: the same boot reports the drift
prisma schema out of sync with dbPre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
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 moreDelays 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 48f0319
Scope is the
--to-schema-datamodelargument ofprisma migrate diffincheck_prisma_schema_diff_helper(litellm/proxy/db/check_migration.py). It was the relative./schema.prisma, which only resolved when the proxy ran from a directory holding a copy, and the repo-root copy moved tolitellm/schema.prismain adc4c01 (#51006). It is now the absolute path oflitellm/proxy/schema.prisma, resolved from the module, which ships in the wheel and in the Docker image and is kept identical to the other copies. Nothing else in the drift check changes, and the only caller is the boot path inproxy_cli.pywhen schema updates are disabled.The bug was found by the Dec 1 integration contract tests (draft PR #50853). The test skipped with BUG for it is
tests/integration/database/test_dec1_deploy_startup_database.py::test_with_schema_updates_disabled_an_empty_database_gets_no_tables(both theenvironmentandconfigcells, in both groups).The new regression test
test_migrate_diff_reads_the_proxy_schema_from_any_working_directoryruns the helper withrun_prismaswapped for an in-process recorder, so no process starts, from a directory with noschema.prismaand checks the schema it was handed is an absolute path to a file declaring the LiteLLM models, with--scriptstill last. It failed before the fix (the argument was the relativeschema.prisma) and passes at the tip. The existing timeout test pinned the old./schema.prismaargument, so it now checks the arguments before and after the path,--scriptincluded.Type
Bug Fix
Final Attestation
Generated by Claude Code