fix(proxy): fail the standalone prisma migration entrypoint on migration errors - #37692
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThe PR makes the standalone Prisma migration entrypoint fail by default when migration or client-generation steps fail, while retaining explicit opt-out behavior
Confidence Score: 5/5The PR appears safe to merge No blocking failure remains
|
| Filename | Overview |
|---|---|
| litellm/proxy/prisma_migration.py | Refactors the standalone entrypoint into a testable main function and propagates migration and Prisma generation failures unless enforcement is explicitly disabled |
| tests/test_litellm/proxy/test_prisma_migration.py | Covers default enforcement, explicit opt-out, Prisma generation exit propagation, and migration failure propagation |
Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…evin/lit-5385-migration-job-exits-0-on-failed-migration-by-default-so
|
@greptileai please review the current head |
…evin/lit-5385-migration-job-exits-0-on-failed-migration-by-default-so
Genuine upstream breakage from this sync's PR BerriAI#37692 (made the standalone entrypoint's prisma generate failure fatal by default instead of log-only), colliding with a real non-root permission constraint: prisma-python's generate() unconditionally re-copies schema.prisma into the installed package and chmod's the copy even when content already matches, and chmod requires owning the destination file, which no arbitrary runtime uid ever does for a file baked into the image at build time. Both runtime images already bake the generated client from this same schema.prisma at build time, so regenerating it at container start was always redundant work. Add LITELLM_PRISMA_CLIENT_PREBAKED to skip the runtime entrypoint's prisma generate call when set, and set it in both Dockerfile and docker/Dockerfile.non_root.
TLDR
Problem this solves:
prisma generatealso exits 0How it solves it:
prisma generatefailure returns its exit codeENFORCE_PRISMA_MIGRATION_CHECK=falserestores the old leniencyUser Flow
Before: a platform engineer upgrading the gateway with ArgoCD sees the sync go green even though the database was never migrated, then the app serves errors against an out-of-date schema
ENFORCE_PRISMA_MIGRATION_CHECK=trueand re-sync does the Job fail and stop the rolloutAfter: the same sync stops at the migration Job, so nothing gets deployed against a stale schema
ENFORCE_PRISMA_MIGRATION_CHECK=falseon the Job and get exit 0 on a failed migration againRelevant issues
Linear ticket
Resolves LIT-5385
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
Shared setup: point the migration entrypoint at an unreachable Postgres so
prisma migrate deployfails, and print the exit code the Job would reportBefore (3a31331)
Failed migration, default settings
Failed migration, ENFORCE_PRISMA_MIGRATION_CHECK=false
After (da75cd5)
Failed migration, default settings
Failed migration, ENFORCE_PRISMA_MIGRATION_CHECK=false
Type
🐛 Bug Fix
Caveats (if any)
docker/entrypoint.shimages also stop on migration failureENFORCE_PRISMA_MIGRATION_CHECK=falseFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/d6ef92e6d1ea4b39ae7aabb14b4dc2a2
Requested by: @yassin-berriai