fix(client): improve adapter-related Prisma 7 error messages - #29624
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (10)
Summary by CodeRabbit
WalkthroughThis PR refactors PrismaClient constructor options from a mutually-exclusive approach to a discriminated union with a shared PrismaClientBaseOptions and two variants (PrismaClientOptionsWithAccelerateUrl, PrismaClientOptionsWithAdapter). Generator outputs (TS and JS) add a PrismaClientConstructorArgs conditional helper type and update generated constructor signatures and doc comments. The PrismaNamespaceFile generator is changed to emit the new option interfaces directly. Runtime initialization/validation error messages and the related test snapshot and AGENTS.md docs were updated to match the new wording. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@AGENTS.md`:
- Line 52: Update the AGENTS.md explanation to match the actual behavior and the
generator comment: clarify that when tsNoCheckPreamble (// `@ts-nocheck`) is
present in the generated prismaNamespace.ts the TypeScript missing-property
diagnostic picks the alphabetically-first union branch (so union order matters
and you should place PrismaClientOptionsWithAccelerateUrl before
PrismaClientOptionsWithAdapter), and ensure the doc references the generator
behavior described in PrismaNamespaceFile.ts and the runtime types ordering in
getPrismaClient.ts; edit the text to state this correctly (or, if behavior
differs, adjust the comment in PrismaNamespaceFile.ts to reflect the real
behavior) so AGENTS.md and PrismaNamespaceFile.ts are consistent about
tsNoCheckPreamble and diagnostic ordering for PrismaClientOptions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 254ebd52-ad8b-484c-a150-29ec75437e7e
📒 Files selected for processing (10)
AGENTS.mdpackages/client-generator-js/src/TSClient/PrismaClient.tspackages/client-generator-js/src/TSClient/common.tspackages/client-generator-ts/src/TSClient/PrismaClient.tspackages/client-generator-ts/src/TSClient/common.tspackages/client-generator-ts/src/TSClient/file-generators/PrismaNamespaceFile.tspackages/client/src/__tests__/validatePrismaClientOptions.test.tspackages/client/src/runtime/core/engines/client/ClientEngine.tspackages/client/src/runtime/getPrismaClient.tspackages/client/src/runtime/utils/validatePrismaClientOptions.ts
size-limit report 📦
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/client/src/runtime/getPrismaClient.ts (1)
388-404:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUnify the no-options constructor error with the validation error.
This branch now emits different wording from
validatePrismaClientOptions({}): the lead sentence changed, and the trailingRead more at https://pris.ly/d/client-constructorline is gone. That breaks the PR's “single concrete message” goal and makesnew PrismaClient()less actionable thannew PrismaClient({}).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/client/src/runtime/getPrismaClient.ts` around lines 388 - 404, The constructor currently throws a PrismaClientInitializationError with wording that diverges from validatePrismaClientOptions({}); update the constructor (the class constructor in getPrismaClient.ts) to reuse the same error text/path as validatePrismaClientOptions by either calling validatePrismaClientOptions({}) and rethrowing its error or importing/using the same message generator/constant used by validatePrismaClientOptions so the lead sentence and the trailing "Read more at https://pris.ly/d/client-constructor" line match exactly; ensure the thrown error remains a PrismaClientInitializationError and reference the constructor and validatePrismaClientOptions symbols when applying the change.packages/client-generator-js/src/TSClient/PrismaClient.ts (1)
618-639:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAlign JS generator
PrismaClientOptionswith runtime/TS (adapterrequired unlessaccelerateUrl)
packages/client-generator-js/src/TSClient/PrismaClient.tsemitsadapteras optional and even omits it entirely for MongoDB-only schemas (guarded bythis.internalDatasources.some((d) => d.provider !== 'mongodb')). This means the generated JS client’s constructor options type doesn’t enforce the runtime contract enforced byvalidatePrismaClientOptions()(at least one ofadapteroraccelerateUrlis required), so missing-adapter diagnostics won’t surface consistently like they do in the TS generator (adapter | accelerateUrlunion).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/client-generator-js/src/TSClient/PrismaClient.ts` around lines 618 - 639, The generated JS PrismaClient options currently mark `adapter` optional and omits it for MongoDB-only schemas (see PrismaClient.ts, `this.internalDatasources` check and the `adapter` property added to `clientOptions`), which diverges from the runtime contract enforced by `validatePrismaClientOptions()` that requires at least one of `adapter` or `accelerateUrl`; update the JS generator so `PrismaClientOptions` reflects that requirement by making the constructor options require `adapter` unless `accelerateUrl` is present (mirror the TS generator behavior), i.e., change the `adapter` declaration logic in `PrismaClient.ts` to produce a union/required constraint matching `accelerateUrl` presence and remove the MongoDB-only omission or replace it with the same conditional typing used in the TS generator so missing-adapter diagnostics surface consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/client-generator-ts/src/TSClient/file-generators/PrismaNamespaceFile.ts`:
- Around line 278-289: Update the misleading comment in PrismaNamespaceFile.ts
that claims the discriminated-union ordering relies on prismaNamespace.ts being
emitted without "// `@ts-nocheck`": change the wording to reflect that the
generator currently prepends "// `@ts-nocheck`" by default (see tsNoCheckPreamble
in generator.ts and addPreambleToSourceFiles in utils/addPreamble.ts), and
adjust the “with/without `@ts-nocheck`” explanation to describe the actual
behavior (i.e., that the ordering heuristic only matters when the preamble does
not include `// `@ts-nocheck``, but the generator currently enables that preamble
by default).
---
Outside diff comments:
In `@packages/client-generator-js/src/TSClient/PrismaClient.ts`:
- Around line 618-639: The generated JS PrismaClient options currently mark
`adapter` optional and omits it for MongoDB-only schemas (see PrismaClient.ts,
`this.internalDatasources` check and the `adapter` property added to
`clientOptions`), which diverges from the runtime contract enforced by
`validatePrismaClientOptions()` that requires at least one of `adapter` or
`accelerateUrl`; update the JS generator so `PrismaClientOptions` reflects that
requirement by making the constructor options require `adapter` unless
`accelerateUrl` is present (mirror the TS generator behavior), i.e., change the
`adapter` declaration logic in `PrismaClient.ts` to produce a union/required
constraint matching `accelerateUrl` presence and remove the MongoDB-only
omission or replace it with the same conditional typing used in the TS generator
so missing-adapter diagnostics surface consistently.
In `@packages/client/src/runtime/getPrismaClient.ts`:
- Around line 388-404: The constructor currently throws a
PrismaClientInitializationError with wording that diverges from
validatePrismaClientOptions({}); update the constructor (the class constructor
in getPrismaClient.ts) to reuse the same error text/path as
validatePrismaClientOptions by either calling validatePrismaClientOptions({})
and rethrowing its error or importing/using the same message generator/constant
used by validatePrismaClientOptions so the lead sentence and the trailing "Read
more at https://pris.ly/d/client-constructor" line match exactly; ensure the
thrown error remains a PrismaClientInitializationError and reference the
constructor and validatePrismaClientOptions symbols when applying the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 73e3c6bd-63f0-48f8-bfae-bc5960496a45
📒 Files selected for processing (10)
AGENTS.mdpackages/client-generator-js/src/TSClient/PrismaClient.tspackages/client-generator-js/src/TSClient/common.tspackages/client-generator-ts/src/TSClient/PrismaClient.tspackages/client-generator-ts/src/TSClient/common.tspackages/client-generator-ts/src/TSClient/file-generators/PrismaNamespaceFile.tspackages/client/src/__tests__/validatePrismaClientOptions.test.tspackages/client/src/runtime/core/engines/client/ClientEngine.tspackages/client/src/runtime/getPrismaClient.tspackages/client/src/runtime/utils/validatePrismaClientOptions.ts
54bf8f2 to
fd3ad63
Compare
Both the runtime and the TypeScript errors that users get when they forget to pass a driver adapter to the `PrismaClient` constructor were confusing and not actionable. Runtime improvements ==================== - Replace the validation error `Using engine type "client" requires either "adapter" or "accelerateUrl" to be provided to PrismaClient constructor.` with a copy-pasteable example that uses `@prisma/adapter-pg` and a link to https://pris.ly/d/driver-adapters. Accelerate is mentioned only as a brief footnote. - Replace the `ClientEngine` defense-in-depth error (`Missing configured driver adapter. Engine type \`client\` requires an active driver adapter.`) with a single-line variant of the same message; drop the "engine type 'client'" wording entirely. - Replace the `PrismaClient was constructed with non-empty…` error from `getPrismaClient` (raised on `new PrismaClient()` with no arguments) with the same concrete example so all three runtime errors agree on wording and call to action. - Update the inline snapshot in `validatePrismaClientOptions.test.ts`. Type improvements ================= - Restructure `PrismaClientOptions` from `(WithAdapter | WithAccelerateUrl) & Base` into a discriminated union of named interfaces: `PrismaClientBaseOptions`, `PrismaClientOptionsWithAdapter`, `PrismaClientOptionsWithAccelerateUrl`, with `PrismaClientOptions = PrismaClientOptionsWithAccelerateUrl | PrismaClientOptionsWithAdapter`. Mirror the same shape in the TS generator (`PrismaNamespaceFile.ts`). - Rich JSDoc on `adapter`/`accelerateUrl` properties with a working example and link to the docs. TypeScript surfaces these in autocomplete (hover doesn't, due to microsoft/TypeScript#32542). - Add a `Prisma.PrismaClientConstructorArgs<Options>` helper used as the constructor parameter type. It resolves to plain `PrismaClientOptions` when `Options` defaults to itself (`new PrismaClient()` or `new PrismaClient({})`), and falls back to `Subset<…>` otherwise. This makes the error message read `not assignable to parameter of type 'PrismaClientOptions'` instead of the noisy `Subset<PrismaClientOptions, PrismaClientOptions>`, while still rejecting unknown properties for literal arguments. Union order matters =================== `PrismaClientOptions` lists the Accelerate branch first and the adapter branch second, in both the runtime types and the TS generator output. TypeScript's missing-property error elaboration for a discriminated union reports against the second union member, so this makes `new PrismaClient({ log: [...] })` say `Property 'adapter' is missing in type … but required in type 'PrismaClientOptionsWithAdapter'` (the recommended option for most users) instead of suggesting `accelerateUrl`. `AGENTS.md` documents this and the other constraints (declaration layout, hover-vs-autocomplete JSDoc behavior, etc.) so future changes don't accidentally regress them. Fixes TML-2681. Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
…29624) Both the runtime and TypeScript errors that users get when they forget to pass a driver adapter to the `PrismaClient` constructor were confusing and not actionable. This PR makes both helpful and points them at the docs. Fixes [TML-2681](https://linear.app/prisma-company/issue/TML-2681/improve-adapter-related-prisma-7-error-messages). ## Runtime improvements - **Validation error** (`packages/client/src/runtime/utils/validatePrismaClientOptions.ts`) — replaces `Using engine type "client" requires either "adapter" or "accelerateUrl" to be provided to PrismaClient constructor.` with a clearer message that includes a copy-pasteable example using `@prisma/adapter-pg` and a link to <https://pris.ly/d/driver-adapters>. Accelerate is mentioned only as a brief footnote so adapter is the obvious primary path. - **Defense-in-depth error in `ClientEngine`** — drops the "engine type `client`" wording and reuses the same single-line message + docs link. - **`new PrismaClient()` with no arguments** (`getPrismaClient.ts`) — replaces the multi-paragraph `PrismaClient needs to be constructed with a non-empty, valid PrismaClientOptions` boilerplate with the same concrete example, so all three runtime errors agree on wording and call to action. - **Inline snapshot** in `validatePrismaClientOptions.test.ts` updated. ## TypeScript improvements - **Restructured `PrismaClientOptions`** from `(WithAdapter | WithAccelerateUrl) & Base` into a discriminated union of named interfaces: - `PrismaClientBaseOptions` - `PrismaClientOptionsWithAdapter` - `PrismaClientOptionsWithAccelerateUrl` - `PrismaClientOptions = PrismaClientOptionsWithAccelerateUrl | PrismaClientOptionsWithAdapter` Mirrored in the TS generator (`PrismaNamespaceFile.ts`). The new TS generator now emits four exported types; the legacy JS generator keeps its single flat `PrismaClientOptions` interface for backwards compatibility but gets the new JSDoc treatment. - **Rich JSDoc** on the `adapter` and `accelerateUrl` properties — full example with `PrismaPg`, a `**required**` callout, and a link to <https://pris.ly/d/driver-adapters>. TypeScript surfaces these in autocomplete (it doesn't on hover after the property is written — that's [microsoft/TypeScript#32542](microsoft/TypeScript#32542), and the same limitation affects query args like `where`/`select`/`take`). - **`Prisma.PrismaClientConstructorArgs<Options>` helper** as the constructor parameter type. It resolves to plain `PrismaClientOptions` when `Options` defaults to itself (i.e. `new PrismaClient()` or `new PrismaClient({})`), and falls back to `Subset<…>` otherwise. So instead of the noisy `Subset<PrismaClientOptions, PrismaClientOptions>`, the error now reads `not assignable to parameter of type 'PrismaClientOptions'`, while still rejecting unknown properties for object-literal arguments. ## Union order matters The `PrismaClientOptions` union lists the Accelerate branch first and the adapter branch second, both in the runtime types and in the generator output. TypeScript's missing-property error elaboration for a discriminated union reports against the second union member, so this makes `new PrismaClient({ log: [...] })` say `Property 'adapter' is missing in type ... but required in type 'PrismaClientOptionsWithAdapter'` (the recommended option for most users) instead of suggesting `accelerateUrl`. `AGENTS.md` documents this and the other constraints so future changes don't accidentally regress them. ## Resulting errors For these three call sites: ```ts new PrismaClient() // ❶ new PrismaClient({}) // ❷ new PrismaClient({ adapter, accelerateUrl: '…' }) // ❸ ``` TypeScript now says: ``` ❶ Expected 1 arguments, but got 0. ❷ Argument of type '{}' is not assignable to parameter of type 'PrismaClientOptions'. ❸ Argument of type '{ adapter: SqlDriverAdapterFactory; accelerateUrl: string; }' is not assignable to parameter of type 'PrismaClientOptions'. Types of property 'accelerateUrl' are incompatible. Type 'string' is not assignable to type 'undefined'. ``` For `new PrismaClient({ log: ['query'] })` (no adapter at all): ``` Argument of type '{ log: "query"[]; }' is not assignable to parameter of type 'PrismaClientOptions'. Property 'adapter' is missing in type '{ log: "query"[]; }' but required in type 'PrismaClientOptionsWithAdapter'. ``` And the runtime validation, if the type system is bypassed: ``` PrismaClientConstructorValidationError: PrismaClient requires a driver adapter to connect to your database, but none was provided. Pass a driver adapter to the PrismaClient constructor, for example: import { PrismaPg } from '@prisma/adapter-pg' import { PrismaClient } from './generated/prisma/client' const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL }) const prisma = new PrismaClient({ adapter }) Learn more about driver adapters: https://pris.ly/d/driver-adapters If you use Prisma Accelerate instead of connecting to your database directly, pass `accelerateUrl` to the PrismaClient constructor instead of `adapter`. Read more at https://pris.ly/d/client-constructor ``` ## Validation - `pnpm --filter @prisma/client exec jest src/__tests__` — 340 passed (including the `types.test.ts` tsd checks). - `pnpm --filter @prisma/client-generator-ts test` — 39 passed. - `pnpm --filter @prisma/client-generator-js test` — 17 passed. - Full `pnpm build` from the root completes (44/44 turborepo tasks). - Sandbox regenerated and the error messages above verified against the real generated client with both `tsc` 5.4 and `tsgo`. Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
This PR contains the following updates: | Package | Type | Update | Change | Pending | |---|---|---|---|---| | [@prisma/adapter-pg](https://github.com/prisma/prisma) ([source](https://github.com/prisma/prisma/tree/HEAD/packages/adapter-pg)) | imports | minor | [`7.8.0` -> `7.9.0`](https://renovatebot.com/diffs/npm/@prisma%2fadapter-pg/7.8.0/7.9.0) | `7.9.1` | | [@prisma/client](https://www.prisma.io) ([source](https://github.com/prisma/prisma/tree/HEAD/packages/client)) | imports | minor | [`7.8.0` -> `7.9.0`](https://renovatebot.com/diffs/npm/@prisma%2fclient/7.8.0/7.9.0) | `7.9.1` | | [prisma](https://www.prisma.io) ([source](https://github.com/prisma/prisma/tree/HEAD/packages/cli)) | imports | minor | [`7.8.0` -> `7.9.0`](https://renovatebot.com/diffs/npm/prisma/7.8.0/7.9.0) | `7.9.1` | --- ### Release Notes <details> <summary>prisma/prisma (@​prisma/adapter-pg)</summary> ### [`v7.9.0`](https://github.com/prisma/prisma/releases/tag/7.9.0) [Compare Source](prisma/orm@7.8.0...7.9.0) Today, we are excited to share the `7.9.0` stable release 🎉 **🌟 Star this repo for notifications about new releases, bug fixes & features — or [follow us on X](https://pris.ly/x)!** ##### Highlights ##### ORM ##### Tab completions for the Prisma CLI Typing out CLI commands from memory is now optional. Prisma ships **shell tab completions** for `bash`, `zsh`, `fish`, and PowerShell, covering commands, subcommands, options, flags, and even option values. **Setting it up.** Most projects run Prisma through a package manager, so completions are enabled through `@bomb.sh/tab`'s package-manager integration — install it once, then source the completion for your package manager and shell: ```bash # 1. Install @​bomb.sh/tab globally npm install -g @​bomb.sh/tab # 2. Wire up your package manager + shell (pnpm shown; swap in npm / yarn / bun): echo 'source <(tab pnpm zsh)' >> ~/.zshrc # zsh echo 'source <(tab pnpm bash)' >> ~/.bashrc # bash tab pnpm fish > ~/.config/fish/completions/pnpm.fish # fish tab pnpm powershell > ~/.tab-pnpm.ps1 # PowerShell (then dot-source it from $PROFILE) ``` `@bomb.sh/tab` delegates to any locally-installed CLI that ships completions, so `pnpm prisma <TAB>`, `pnpm exec prisma <TAB>`, `yarn prisma <TAB>`, and `bun x prisma <TAB>` all complete Prisma's commands, options, and values — no per-project setup. (`npx` and `bunx` don't support completion themselves; use `npm exec` and `bun x`.) If instead you have Prisma installed globally on your `PATH`, source its own completion directly: `source <(prisma complete zsh)` (or the `bash` / `fish` / `powershell` variant). This is built on [`@bomb.sh/tab`](https://github.com/bombshell-dev/tab/), the same completion library that powers other CLIs in the ecosystem — including Cloudflare, Nuxt, and Vitest — so the package-manager completions you enable for Prisma work for those tools too. A wonderful community contribution from [@​AmirSa12](https://github.com/AmirSa12) ([#​28351](prisma/orm#28351)) — thank you! <https://github.com/user-attachments/assets/1f916a60-ee4d-40be-bb7d-74035d48ca83> ##### Prisma ORM, ready for AI agents Coding agents are now a first-class audience for Prisma, and 7.9.0 brings the first wave of work to make Prisma projects safe and productive for them to work in. **Agent skills installed with `prisma init`** ([#​29689](prisma/orm#29689)) `prisma init` now installs the [prisma/skills](https://github.com/prisma/skills) catalog into freshly scaffolded projects. Agents such as Claude Code, Cursor, Codex, and Windsurf start out with current, version-relevant Prisma knowledge instead of relying on whatever happened to be in their training data. The install is best-effort and never blocks scaffolding; opt out at any time with `--no-skills`. ```terminal npx prisma@latest init ```  **A safer default around destructive commands** ([#​29684](prisma/orm#29684), [#​29691](prisma/orm#29691), [#​29713](prisma/orm#29713)) Prisma's AI safety checkpoint refuses to run destructive commands when it detects that an AI agent is at the keyboard, unless the user has given explicit consent. In this release we: - **Broadened agent detection** to cover today's landscape — Codex CLI (now on Linux as well as macOS), Qwen Code, GitHub Copilot CLI, OpenCode, Cline, Goose, Amp, Crush, Augment Code, Antigravity, Replit Agent, and Devin — plus generic `AI_AGENT` / `AGENT` conventions so future agents are caught without a code change. - **Extended the guard to `db push --accept-data-loss`**, which previously bypassed the checkpoint even though it can drop data. - **Removed the `migrate-reset` tool from the `prisma mcp` server** entirely — resetting a database drops it, and that is not an operation an agent should be handed as a first-class tool. An agent that needs a reset must run the CLI, where the checkpoint applies. ##### Bug Fixes Many of the fixes below are **community contributions** — thank you to everyone who reported and fixed these! **Prisma Client** - Fixed a severe TypeScript performance regression introduced in Prisma 7: restoring the `OmitOpts` generic default lets `tsc` reuse cached type instantiations again, bringing type-checking on large schemas back from minutes to seconds ([#​29592](prisma/orm#29592), from [@​nfl1ryxditimo12](https://github.com/nfl1ryxditimo12)). - The `XOR` type helper now rejects primitive values such as `data: 5`, which were previously accepted at compile time even though the runtime rejected them ([#​29735](prisma/orm#29735), from [@​kyungseopk1m](https://github.com/kyungseopk1m)). - `$queryRaw` and `$executeRaw` now fail fast with a clear validation error when passed an invalid `Date`, instead of silently serializing it as `null` and corrupting the value sent to the database ([#​29697](prisma/orm#29697), from [@​jibin7jose](https://github.com/jibin7jose)). - The generated client is no longer corrupted by a `///` documentation comment that contains a `*/` sequence; the comment terminator is now escaped when doc comments are emitted, in both the TypeScript and JavaScript generators ([#​29736](prisma/orm#29736), from [@​kyungseopk1m](https://github.com/kyungseopk1m)). - Improved the runtime and TypeScript error messages shown when a driver adapter is missing from the `PrismaClient` constructor; both now include a copy-pasteable example and a link to the [driver adapters docs](https://pris.ly/d/driver-adapters) ([#​29624](prisma/orm#29624)). - Unmapped database errors from driver adapters now surface as a user-facing `P2039` (`PrismaClientKnownRequestError`) carrying the original code and message, instead of an opaque failure, which keeps schema-drift-style problems debuggable ([#​29512](prisma/orm#29512)). - The `prisma-client-js` generator no longer emits a stray `undefined` statement when generating from a schema that declares only enums or types and no models ([#​29738](prisma/orm#29738), from [@​kyungseopk1m](https://github.com/kyungseopk1m)). - Fixed a connection leak when an interactive transaction times out (`maxWait`) while it is still starting: the discarded transaction now sends an explicit `ROLLBACK` before the connection is returned to the pool, instead of releasing it mid-transaction. Previously, on adapters like `@prisma/adapter-pg` and `@prisma/adapter-neon`, the next query to reuse that connection could fail with `there is already a transaction in progress` — or silently commit the leaked transaction's work ([#​29727](prisma/orm#29727), from [@​lazerg](https://github.com/lazerg)). **CLI** - `prisma validate` (and other schema-loading commands) no longer hangs forever on a multi-file schema whose directories contain a symlink cycle, and no longer reports the same file twice when a directory is reachable under two spellings (e.g. `/tmp` → `/private/tmp` on macOS) ([#​29740](prisma/orm#29740), from [@​kyungseopk1m](https://github.com/kyungseopk1m)). - On Windows, engine binaries are now cached in a stable, user-level directory (`%APPDATA%\Prisma`) instead of a `cwd`-relative `node_modules\.cache`, which eliminated duplicate cache directories and the bloated Serverless/Docker bundles they caused ([#​29730](prisma/orm#29730), from [@​santichausis](https://github.com/santichausis); closes [#​22574](prisma/orm#22574), [#​6670](prisma/orm#6670), [#​11577](prisma/orm#11577)). **Driver Adapters** - **[@​prisma/adapter-pg](https://github.com/prisma/adapter-pg)**, **[@​prisma/adapter-neon](https://github.com/prisma/adapter-neon)**, **[@​prisma/adapter-ppg](https://github.com/prisma/adapter-ppg)**: Reading a `Bytes` column no longer emits Node.js' `DEP0005` deprecation warning, thanks to an upstream `postgres-bytea` bump ([#​29538](prisma/orm#29538), from [@​kolia-zamnius](https://github.com/kolia-zamnius)). - **[@​prisma/adapter-ppg](https://github.com/prisma/adapter-ppg)**: `ColumnNotFound` (`P2022`) errors now parse both quoted and unquoted PostgreSQL column names, including identifiers containing spaces, matching the fix previously applied to `adapter-pg` ([#​29737](prisma/orm#29737), from [@​kyungseopk1m](https://github.com/kyungseopk1m)). - **[@​prisma/adapter-mssql](https://github.com/prisma/adapter-mssql)**: Setting a `Bytes?` (`@db.VarBinary`) field to `null` no longer fails with an implicit-conversion error; the adapter now sends the parameter typed as `VarBinary` instead of letting SQL Server default it to `nvarchar` ([#​29630](prisma/orm#29630), from [@​AnupamKumar-1](https://github.com/AnupamKumar-1)). **Schema Engine** - `prisma migrate status` now reports a rolled-back migration that still exists on disk as *unapplied*, instead of incorrectly treating the schema as up to date ([prisma/prisma-engines#5817](prisma/prisma-engines#5817), from [@​goutamadwant](https://github.com/goutamadwant)). - Primary-key constraint renames are now rendered as separate `ALTER TABLE` statements on PostgreSQL, avoiding a database error when a single table has multiple changes in one migration ([prisma/prisma-engines#4906](prisma/prisma-engines#4906), from [@​eruditmorina](https://github.com/eruditmorina)). ##### Security - Resolved the `hono` security advisories at their source: `@prisma/dev` was updated to a version that no longer depends on `hono` at all, so the CLI is no longer exposed to those advisories through that path. We also patched moderate-severity advisories in `ajv` and `uuid` across production dependencies ([#​29514](prisma/orm#29514)). - Hardened the Prisma Platform credentials file (`~/.config/prisma-platform/auth.json`) and its directory to `0o600` / `0o700` so OAuth tokens are no longer world-readable, bringing Prisma in line with the GitHub, AWS, and Google Cloud CLIs ([#​29568](prisma/orm#29568), from Jaeyoung Yun). - Bumped the `openssl` crate in the schema engine binaries from 0.10.74 to 0.10.81 ([prisma/prisma-engines#5815](prisma/prisma-engines#5815)). ##### Prisma Studio The bundled Prisma Studio moves from `0.27.3` to `0.33.0` ([#​29720](prisma/orm#29720)), gathering up everything shipped in the Studio releases in between. ##### Migrations view Studio can now visualise your **migration history**. This view is powered by **[Prisma Next](https://www.prisma.io/docs/orm/next)** — the next major version of Prisma ORM, a full TypeScript rewrite (available now in [Early Access](https://www.prisma.io/docs/next/getting-started)) that keeps the schema-first workflow and model-first queries you know, but treats your schema as a versioned, inspectable **contract** instead of compiling it into a heavy generated client. Prisma Next records every migration and its contract snapshots in the database, and Studio reads them to draw the timeline and diff below. Databases managed with classic Prisma Migrate don't carry this ledger, so the view simply stays hidden there. When the connected database has a Prisma Next migration ledger, a **Migrations** entry appears in the sidebar: a newest-first timeline of every applied migration with its name, apply time, operation count, and compact chips summarizing what changed (`+2 models`, `~2 models +3 fields`, `+1 model`, …). Selecting a migration opens a visual, FigJam-style diff canvas — added, removed, and changed models as colour-coded cards (`NEW` / `UPDATED` / `UNCHANGED`) with per-field before → after details, enum cards, and relation edges — next to a SQL panel of the executed statements and a Prisma-schema line diff. Switching migrations morphs the canvas rather than rebuilding it.  <!-- On publishing: drag wip/demos/prisma-studio-migrations.webp into the GitHub release editor so it becomes a user-attachments URL. --> ##### Prisma Streams browser Studio gains first-class support for Prisma Streams: a dedicated stream browser, live stream aggregations, stream diagnostics, routing-key browsing, and a WAL-history handoff straight from your tables, plus richer stream request observability with concise event-log and OpenTelemetry span summaries. ##### Working with SQL - SQL execution, linting, and navigation are now **schema-aware**: unqualified identifiers resolve against the schema you've selected instead of always falling back to the adapter's default schema. - SQL result visualizations are rendered with Studio-owned chart configuration, and there's an optional **Queries** view backed by query-insights snapshots. - Added copy actions to the Query Details view. ##### Fixes - Fixed editing PostgreSQL text-array cells when queries are compiled with inline values. - Avoided cancelling and repeating introspection requests when Studio first mounts, removing duplicate startup work. ##### Thanks to our contributors A heartfelt thank you to the community members whose contributions shaped this release: [@​AmirSa12](https://github.com/AmirSa12), [@​kyungseopk1m](https://github.com/kyungseopk1m), [@​nfl1ryxditimo12](https://github.com/nfl1ryxditimo12), [@​jibin7jose](https://github.com/jibin7jose), [@​santichausis](https://github.com/santichausis), [@​kolia-zamnius](https://github.com/kolia-zamnius), [@​goutamadwant](https://github.com/goutamadwant), [@​eruditmorina](https://github.com/eruditmorina), [@​lazerg](https://github.com/lazerg), [@​AnupamKumar-1](https://github.com/AnupamKumar-1), [@​Swapanrishi](https://github.com/Swapanrishi), [@​anupamme](https://github.com/anupamme), and [@​oyi77](https://github.com/oyi77). ##### Prisma Compute is now in public beta **"Push code, it runs."** [Prisma Compute](https://www.prisma.io/compute) — managed hosting for TypeScript apps that run right next to your database — is now available in [public beta](https://blog.prisma.io/blog/launching-prisma-compute-public-beta), and free to use while the beta lasts. Compute deploys your app as a long-lived process on Bun, colocated with your Prisma Postgres database, so there are no cold starts, no request timeouts, and no separate hosting vendor to wire up. It's a fit for REST and GraphQL APIs, full-stack apps, streaming and gRPC, and the long-running, stateful AI agents that keep connections open and hold in-process caches — "self-hosting, without the painful parts". - **Push-to-deploy** from the CLI or via GitHub integration. Every deployment is an immutable, versioned release with its own preview URL, and rolling back is simply promoting a previous version. - **Branch-based environments** — each branch gets its own app and database, so you can preview a change before promoting it to production. - **Auto-wires with Prisma Postgres** (or bring any database), with automatic health checks and self-recovery. - **[Custom domains](https://blog.prisma.io/blog/prisma-compute-custom-domains)** — point a single CNAME at Prisma and Compute provisions and renews the TLS certificate for you, with no manual certificate uploads or private-key handling. With Prisma ORM for type-safe data access, Prisma Postgres for the managed database, and now Prisma Compute for hosting, the whole stack lives in one place. Read the full story in the [Prisma Compute blog series](https://blog.prisma.io/blog/series/prisma-compute). ##### Enterprise support Thousands of teams use Prisma and many of them already tap into our Enterprise & Agency Support Program for hands-on help with everything from schema integrations and performance tuning to security and compliance. With this program you also get priority issue triage and bug fixes, expert scalability advice, and custom training so that your Prisma-powered apps stay rock-solid at any scale. Learn more or join: <https://prisma.io/enterprise>. </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNzIuMSIsInVwZGF0ZWRJblZlciI6IjQzLjI3Mi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://git.oirnoir.dev/OIRNOIR/YouTube-Helper-Server/pulls/30
…29624) Both the runtime and TypeScript errors that users get when they forget to pass a driver adapter to the `PrismaClient` constructor were confusing and not actionable. This PR makes both helpful and points them at the docs. Fixes [TML-2681](https://linear.app/prisma-company/issue/TML-2681/improve-adapter-related-prisma-7-error-messages). ## Runtime improvements - **Validation error** (`packages/client/src/runtime/utils/validatePrismaClientOptions.ts`) — replaces `Using engine type "client" requires either "adapter" or "accelerateUrl" to be provided to PrismaClient constructor.` with a clearer message that includes a copy-pasteable example using `@prisma/adapter-pg` and a link to <https://pris.ly/d/driver-adapters>. Accelerate is mentioned only as a brief footnote so adapter is the obvious primary path. - **Defense-in-depth error in `ClientEngine`** — drops the "engine type `client`" wording and reuses the same single-line message + docs link. - **`new PrismaClient()` with no arguments** (`getPrismaClient.ts`) — replaces the multi-paragraph `PrismaClient needs to be constructed with a non-empty, valid PrismaClientOptions` boilerplate with the same concrete example, so all three runtime errors agree on wording and call to action. - **Inline snapshot** in `validatePrismaClientOptions.test.ts` updated. ## TypeScript improvements - **Restructured `PrismaClientOptions`** from `(WithAdapter | WithAccelerateUrl) & Base` into a discriminated union of named interfaces: - `PrismaClientBaseOptions` - `PrismaClientOptionsWithAdapter` - `PrismaClientOptionsWithAccelerateUrl` - `PrismaClientOptions = PrismaClientOptionsWithAccelerateUrl | PrismaClientOptionsWithAdapter` Mirrored in the TS generator (`PrismaNamespaceFile.ts`). The new TS generator now emits four exported types; the legacy JS generator keeps its single flat `PrismaClientOptions` interface for backwards compatibility but gets the new JSDoc treatment. - **Rich JSDoc** on the `adapter` and `accelerateUrl` properties — full example with `PrismaPg`, a `**required**` callout, and a link to <https://pris.ly/d/driver-adapters>. TypeScript surfaces these in autocomplete (it doesn't on hover after the property is written — that's [microsoft/TypeScript#32542](microsoft/TypeScript#32542), and the same limitation affects query args like `where`/`select`/`take`). - **`Prisma.PrismaClientConstructorArgs<Options>` helper** as the constructor parameter type. It resolves to plain `PrismaClientOptions` when `Options` defaults to itself (i.e. `new PrismaClient()` or `new PrismaClient({})`), and falls back to `Subset<…>` otherwise. So instead of the noisy `Subset<PrismaClientOptions, PrismaClientOptions>`, the error now reads `not assignable to parameter of type 'PrismaClientOptions'`, while still rejecting unknown properties for object-literal arguments. ## Union order matters The `PrismaClientOptions` union lists the Accelerate branch first and the adapter branch second, both in the runtime types and in the generator output. TypeScript's missing-property error elaboration for a discriminated union reports against the second union member, so this makes `new PrismaClient({ log: [...] })` say `Property 'adapter' is missing in type ... but required in type 'PrismaClientOptionsWithAdapter'` (the recommended option for most users) instead of suggesting `accelerateUrl`. `AGENTS.md` documents this and the other constraints so future changes don't accidentally regress them. ## Resulting errors For these three call sites: ```ts new PrismaClient() // ❶ new PrismaClient({}) // ❷ new PrismaClient({ adapter, accelerateUrl: '…' }) // ❸ ``` TypeScript now says: ``` ❶ Expected 1 arguments, but got 0. ❷ Argument of type '{}' is not assignable to parameter of type 'PrismaClientOptions'. ❸ Argument of type '{ adapter: SqlDriverAdapterFactory; accelerateUrl: string; }' is not assignable to parameter of type 'PrismaClientOptions'. Types of property 'accelerateUrl' are incompatible. Type 'string' is not assignable to type 'undefined'. ``` For `new PrismaClient({ log: ['query'] })` (no adapter at all): ``` Argument of type '{ log: "query"[]; }' is not assignable to parameter of type 'PrismaClientOptions'. Property 'adapter' is missing in type '{ log: "query"[]; }' but required in type 'PrismaClientOptionsWithAdapter'. ``` And the runtime validation, if the type system is bypassed: ``` PrismaClientConstructorValidationError: PrismaClient requires a driver adapter to connect to your database, but none was provided. Pass a driver adapter to the PrismaClient constructor, for example: import { PrismaPg } from '@prisma/adapter-pg' import { PrismaClient } from './generated/prisma/client' const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL }) const prisma = new PrismaClient({ adapter }) Learn more about driver adapters: https://pris.ly/d/driver-adapters If you use Prisma Accelerate instead of connecting to your database directly, pass `accelerateUrl` to the PrismaClient constructor instead of `adapter`. Read more at https://pris.ly/d/client-constructor ``` ## Validation - `pnpm --filter @prisma/client exec jest src/__tests__` — 340 passed (including the `types.test.ts` tsd checks). - `pnpm --filter @prisma/client-generator-ts test` — 39 passed. - `pnpm --filter @prisma/client-generator-js test` — 17 passed. - Full `pnpm build` from the root completes (44/44 turborepo tasks). - Sandbox regenerated and the error messages above verified against the real generated client with both `tsc` 5.4 and `tsgo`. Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Both the runtime and TypeScript errors that users get when they forget to pass a driver adapter to the
PrismaClientconstructor were confusing and not actionable. This PR makes both helpful and points them at the docs.Fixes TML-2681.
Runtime improvements
packages/client/src/runtime/utils/validatePrismaClientOptions.ts) — replacesUsing engine type "client" requires either "adapter" or "accelerateUrl" to be provided to PrismaClient constructor.with a clearer message that includes a copy-pasteable example using@prisma/adapter-pgand a link to https://pris.ly/d/driver-adapters. Accelerate is mentioned only as a brief footnote so adapter is the obvious primary path.ClientEngine— drops the "engine typeclient" wording and reuses the same single-line message + docs link.new PrismaClient()with no arguments (getPrismaClient.ts) — replaces the multi-paragraphPrismaClient needs to be constructed with a non-empty, valid PrismaClientOptionsboilerplate with the same concrete example, so all three runtime errors agree on wording and call to action.validatePrismaClientOptions.test.tsupdated.TypeScript improvements
Restructured
PrismaClientOptionsfrom(WithAdapter | WithAccelerateUrl) & Baseinto a discriminated union of named interfaces:PrismaClientBaseOptionsPrismaClientOptionsWithAdapterPrismaClientOptionsWithAccelerateUrlPrismaClientOptions = PrismaClientOptionsWithAccelerateUrl | PrismaClientOptionsWithAdapterMirrored in the TS generator (
PrismaNamespaceFile.ts). The new TS generator now emits four exported types; the legacy JS generator keeps its single flatPrismaClientOptionsinterface for backwards compatibility but gets the new JSDoc treatment.Rich JSDoc on the
adapterandaccelerateUrlproperties — full example withPrismaPg, a**required**callout, and a link to https://pris.ly/d/driver-adapters. TypeScript surfaces these in autocomplete (it doesn't on hover after the property is written — that's microsoft/TypeScript#32542, and the same limitation affects query args likewhere/select/take).Prisma.PrismaClientConstructorArgs<Options>helper as the constructor parameter type. It resolves to plainPrismaClientOptionswhenOptionsdefaults to itself (i.e.new PrismaClient()ornew PrismaClient({})), and falls back toSubset<…>otherwise. So instead of the noisySubset<PrismaClientOptions, PrismaClientOptions>, the error now readsnot assignable to parameter of type 'PrismaClientOptions', while still rejecting unknown properties for object-literal arguments.Union order matters
The
PrismaClientOptionsunion lists the Accelerate branch first and the adapter branch second, both in the runtime types and in the generator output. TypeScript's missing-property error elaboration for a discriminated union reports against the second union member, so this makesnew PrismaClient({ log: [...] })sayProperty 'adapter' is missing in type ... but required in type 'PrismaClientOptionsWithAdapter'(the recommended option for most users) instead of suggestingaccelerateUrl.AGENTS.mddocuments this and the other constraints so future changes don't accidentally regress them.Resulting errors
For these three call sites:
TypeScript now says:
For
new PrismaClient({ log: ['query'] })(no adapter at all):And the runtime validation, if the type system is bypassed:
Validation
pnpm --filter @prisma/client exec jest src/__tests__— 340 passed (including thetypes.test.tstsd checks).pnpm --filter @prisma/client-generator-ts test— 39 passed.pnpm --filter @prisma/client-generator-js test— 17 passed.pnpm buildfrom the root completes (44/44 turborepo tasks).tsc5.4 andtsgo.