fix(adapter-{pg,neon,ppg}): handle 22P02 error in Postgres#28849
Merged
Conversation
57ed9b4 to
00e9c58
Compare
Contributor
WalkthroughAdds mapping for PostgreSQL error code 22P02 to a new MappedError variant Changes
sequenceDiagram
autonumber
participant App as Application (test)
participant Client as Prisma Client
participant Adapter as DB Adapter (pg/neon/ppg)
participant Utils as driver-adapter-utils
participant DB as PostgreSQL
App->>Client: perform write using enum value "PENDING"
Client->>Adapter: send SQL insert
Adapter->>DB: execute query
DB-->>Adapter: error 22P02 (invalid input value for enum)
Adapter->>Utils: mapDriverError(error 22P02)
Utils-->>Adapter: { kind: "InvalidInputValue", message }
Adapter-->>Client: throw converted driver error containing MappedError
Client->>Client: map InvalidInputValue -> P2007 (user-facing error)
Client-->>App: throw PrismaClientKnownRequestError (code P2007, message)
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
00e9c58 to
5dad1ad
Compare
Handle "invalid text representation"/"invalid input value" (22P02) errors when using Postgres with pg, neon, or ppg adapters, so that they are mapped to a proper user facing error. See this 500 error in QPE that occurred in production: https://prisma-company.slack.com/archives/C04EPL7N2KV/p1764862201609579?thread_ts=1764849204.552389&cid=C04EPL7N2KV Closes: https://linear.app/prisma-company/issue/TML-1664/fix-incorrect-500-error-returned-from-qpe-instead-of-400
5dad1ad to
64c9ada
Compare
Contributor
|
Client memory tests, node 24, client: |
Contributor
size-limit report 📦
|
jacek-prisma
previously approved these changes
Dec 5, 2025
jacek-prisma
approved these changes
Dec 5, 2025
This was referenced Dec 22, 2025
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handle "invalid text representation"/"invalid input value" (22P02) errors when using Postgres with pg, neon, or ppg adapters, so that they are mapped to a proper user facing error.
See this 500 error in QPE that occurred in production: https://prisma-company.slack.com/archives/C04EPL7N2KV/p1764862201609579?thread_ts=1764849204.552389&cid=C04EPL7N2KV
Closes: https://linear.app/prisma-company/issue/TML-1664/fix-incorrect-500-error-returned-from-qpe-instead-of-400
Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.