GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: fix accidental query plan mutation by jacek-prisma · Pull Request #29262 · prisma/orm

Conversation

@jacek-prisma

@jacek-prisma jacek-prisma commented Feb 26, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

TML-1946

Fixes a bug where the query interpreter would unintentionally mutate the query plan. I've marked all of the query plan bits as readonly in the query interpreter to prevent similar issues.

Fixes #29254

Summary by CodeRabbit

  • Tests

    • Added functional tests, a test matrix and a dynamic schema to cover query-plan cache mutation and paging scenarios.
  • Refactor

    • Enforced immutability across the query runtime and rendering pipeline by using DeepReadonly/DeepUnreadonly and safer cloning where needed.
    • Introduced deep readonly/unreadonly type utilities.
  • Bug Fixes

    • Made parameter and field collections readonly in public signatures to prevent accidental mutations.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Feb 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5586903 and 8eac6d9.

📒 Files selected for processing (3)
  • packages/client-engine-runtime/src/interpreter/in-memory-processing.ts
  • packages/client-engine-runtime/src/interpreter/query-interpreter.ts
  • packages/client-engine-runtime/src/interpreter/validation.ts

Walkthrough

Applied recursive DeepReadonly/DeepUnreadonly types across client-engine-runtime, tightened multiple public/internal function signatures to accept readonly inputs, added cloneObject(), adjusted array mutability for params/fields, and added a functional test suite reproducing query-plan cache mutation (cursor pagination) behavior.

Changes

Cohort / File(s) Summary
Type utilities
packages/client-engine-runtime/src/utils.ts
Added DeepReadonly<T> and DeepUnreadonly<T> type utilities.
Events
packages/client-engine-runtime/src/events.ts
QueryEvent.params changed from unknown[] to readonly unknown[].
Interpreter: core & helpers
packages/client-engine-runtime/src/interpreter/query-interpreter.ts, packages/client-engine-runtime/src/interpreter/in-memory-processing.ts
Many interpreter signatures tightened to accept DeepReadonly<...>; run, interpretNode, and other internals updated; added cloneObject<T>(); getRecordKey() now accepts readonly string[].
Query rendering
packages/client-engine-runtime/src/interpreter/render-query.ts
Render and fragment helper APIs now accept/return DeepReadonly types and readonly parameter arrays (e.g., renderQuery, renderRawSql, pairFragmentsWithParams).
Validation & tracing
packages/client-engine-runtime/src/interpreter/validation.ts, packages/client-engine-runtime/src/tracing.ts
performValidation() and withQuerySpanAndEvent() signatures updated to accept DeepReadonly variants; added DeepReadonly imports.
Functional tests: query-plan cache mutation
packages/client/tests/functional/issues/29254-query-plan-cache-mutation/_matrix.ts, packages/client/tests/functional/issues/29254-query-plan-cache-mutation/prisma/_schema.ts, packages/client/tests/functional/issues/29254-query-plan-cache-mutation/tests.ts
Added test matrix, dynamic Prisma schema generator, and tests that exercise sequential cursor pagination to detect query-plan cache mutation regressions.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: fix accidental query plan mutation' directly and clearly describes the main change: preventing unintended mutations to query plans via readonly type constraints.
Linked Issues check ✅ Passed All code requirements from issue #29254 are met: query plan integrity protection via DeepReadonly/DeepUnreadonly types prevents mutation, per-request cursor parameters are preserved, and a regression test with the failing scenario is included.
Out of Scope Changes check ✅ Passed All changes directly address the root cause (query plan mutations) and requirements: type safety enhancements, immutability utilities, and regression test suite are all within scope of fixing accidental query plan mutation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/fix-query-plan-mutation

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.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jacek-prisma
fix: fix accidental query plan mutation
c808dd5
@jacek-prisma
jacek-prisma force-pushed the fix/fix-query-plan-mutation branch from a0d8e5a to c808dd5 Compare February 26, 2026 18:06
coderabbitai[bot]
coderabbitai Bot reviewed Feb 26, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76bb95b and c808dd5.

📒 Files selected for processing (10)
  • packages/client-engine-runtime/src/events.ts
  • packages/client-engine-runtime/src/interpreter/in-memory-processing.ts
  • packages/client-engine-runtime/src/interpreter/query-interpreter.ts
  • packages/client-engine-runtime/src/interpreter/render-query.ts
  • packages/client-engine-runtime/src/interpreter/validation.ts
  • packages/client-engine-runtime/src/tracing.ts
  • packages/client-engine-runtime/src/utils.ts
  • packages/client/tests/functional/issues/29254-query-plan-cache-mutation/_matrix.ts
  • packages/client/tests/functional/issues/29254-query-plan-cache-mutation/prisma/_schema.ts
  • packages/client/tests/functional/issues/29254-query-plan-cache-mutation/tests.ts

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/client-engine-runtime/src/interpreter/render-query.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/client/tests/functional/issues/29254-query-plan-cache-mutation/tests.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Feb 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
packages/client/runtime/index-browser.js 2.23 KB (0%)
packages/client/runtime/index-browser.d.ts 3.28 KB (0%)
packages/cli/build/index.js 2.5 MB (0%)
packages/client/prisma-client-0.0.0.tgz 26.81 MB (+0.01% 🔺)
packages/cli/prisma-0.0.0.tgz 12.84 MB (0%)
packages/bundle-size/da-workers-libsql/output.tgz 1.33 MB (+0.01% 🔺)
packages/bundle-size/da-workers-neon/output.tgz 1.39 MB (+0.01% 🔺)
packages/bundle-size/da-workers-pg/output.tgz 1.38 MB (+0.01% 🔺)
packages/bundle-size/da-workers-planetscale/output.tgz 1.33 MB (+0.01% 🔺)
packages/bundle-size/da-workers-d1/output.tgz 1.3 MB (+0.01% 🔺)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jacek-prisma
chore: address comments
a943513
aqrln
aqrln reviewed Feb 27, 2026
View reviewed changes
Comment thread packages/client-engine-runtime/src/interpreter/query-interpreter.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

aqrln
aqrln reviewed Feb 27, 2026
View reviewed changes
Comment thread packages/client-engine-runtime/src/utils.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

aqrln
aqrln reviewed Feb 27, 2026
View reviewed changes
Comment thread packages/client-engine-runtime/src/utils.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

jacek-prisma added 2 commits February 27, 2026 11:47
@jacek-prisma
chore: address comments
828ff1f
@jacek-prisma
Merge remote-tracking branch 'origin/main' into fix/fix-query-plan-mu…
5586903
…tation
@jacek-prisma
jacek-prisma requested a review from aqrln February 27, 2026 11:48
coderabbitai[bot]
coderabbitai Bot reviewed Feb 27, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a943513 and 5586903.

📒 Files selected for processing (1)
  • packages/client-engine-runtime/src/utils.ts

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/client-engine-runtime/src/utils.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/client-engine-runtime/src/utils.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

aqrln
aqrln approved these changes Feb 27, 2026
View reviewed changes
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Feb 27, 2026
jacek-prisma added 2 commits February 27, 2026 13:40
@jacek-prisma
Merge branch 'main' into fix/fix-query-plan-mutation
71a07e1
@jacek-prisma
chore: fix broken merge
8eac6d9
@jacek-prisma
jacek-prisma merged commit 6586972 into main Feb 27, 2026
249 of 250 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@jacek-prisma
jacek-prisma deleted the fix/fix-query-plan-mutation branch February 27, 2026 14:00
jacek-prisma added a commit that referenced this pull request Feb 27, 2026
@jacek-prisma
fix: fix accidental query plan mutation (#29262)
cf5a869
[TML-1946](https://linear.app/prisma-company/issue/TML-1946/investigate-and-fix-null-cursor-regression)

Fixes a bug where the query interpreter would unintentionally mutate the
query plan. I've marked all of the query plan bits as readonly in the
query interpreter to prevent similar issues.

Fixes #29254

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Added functional tests, a test matrix and a dynamic schema to cover
query-plan cache mutation and paging scenarios.

* **Refactor**
* Enforced immutability across the query runtime and rendering pipeline
by using DeepReadonly/DeepUnreadonly and safer cloning where needed.
  * Introduced deep readonly/unreadonly type utilities.

* **Bug Fixes**
* Made parameter and field collections readonly in public signatures to
prevent accidental mutations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@tensordreams tensordreams mentioned this pull request Jul 22, 2026
perf: purified plans #29004
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@aqrln aqrln aqrln approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Prisma 7.4 breaks cursor pagination when sorted by a nullable field

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jacek-prisma @aqrln
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.