Skip to content

fix(adapters): a query error names its operation and table on every dialect - #1807

Merged
mobeenabdullah merged 2 commits into
mainfrom
fix/query-errors-carry-their-context-on-every-dialect
Sep 11, 2026
Merged

mobeenabdullah merged 2 commits into
mainfrom
fix/query-errors-carry-their-context-on-every-dialect

Conversation

@mobeenabdullah

Copy link
Copy Markdown
Collaborator

What

Repairs main's red Integration (postgres) and Integration (mysql) legs, which my #1787 turned red, by fixing the adapter behaviour the failing assertion caught: a query error now carries its operation-and-table context on every dialect.

Ledger: task:query-errors-carry-their-context, fixing finding:query-error-context-skipped-on-pg-mysql; research research:query-error-context-check.

What was true on main (95cfddac3)

  • Both legs fail one test from feat(adapters): the transactional update writes the physical table, as the insert does #1787: adapter-{postgres,mysql}/…/transaction-update-writes-the-table.integration.test.ts › refuses a column the table does not have, naming the operation and the table. Received: a DatabaseError with table: "int_txpg_update_table" and message Failed query: UPDATE "int_txpg_update_table" …; expected /update operation failed.*ghost/s. feat(adapters): the transactional update writes the physical table, as the insert does #1787's merge commit had these legs skipped by the newer-push rule, so the next push to main was their first run; the twins self-skip locally (no Docker here), so the SQLite twin was the only one I ran. That is on me.
  • The cause is in DrizzleAdapter.handleQueryError: it prefixes <op> operation failed on table '<t>': only if (!message.includes(operation)) — a proxy for "the context is not there yet". The table's name contains update, so the proxy said yes.
  • It is wider than this test. Drizzle spells its statements in lower case (pg-core/dialect.js: delete from, update … set, insert into; mysql-core the same) and wraps a driver error as Failed query: <sql>\nparams: … (errors.js). So on PostgreSQL and MySQL the message names the operation for every query-builder statement, and the context has effectively never been attached there.

How

handleQueryError now asks whether the context it writes is present — message.includes("<op> operation failed on table '<t>'") — rather than whether the operation's bare name appears. Same method, same shape, attached once however often one error is handled (classifyError returns an existing DatabaseError unchanged, so a re-handled error must not stack the prefix).

Who reads the message: git grep 'operation failed' finds only the three twin assertions; no product code parses it, and nextly maps a DatabaseError to its public response by kind (NextlyError.fromDatabaseError), never by driver text. So this changes diagnostic text only, on PostgreSQL and MySQL, where the context was missing.

Verification

  • Three base-class tests in adapter-drizzle/src/__tests__/adapter.test.ts (they run everywhere, unlike the pg/mysql twins): a Drizzle-shaped lower-case statement message gets the context; a message where only a name contains the operation gets it; handling the same error twice attaches it once.
  • Break-verified: restoring the bare-word check fails exactly the first two (2/21); "always prefix" fails exactly the third (1/21). Restored: 21/21.
  • Gates at c42424c95 (main 746a7141c merged in): adapter-drizzle, -sqlite, -postgres, -mysql lint 0 and check-types 0 (after rebuilding adapter-drizzle's dist); unit 184 / 66 / 87 / 47; SQLite integration twin 35/35; pnpm exec fallow audit --changed-since origin/main --gate new-only (3.15.0) pass, 0 introduced.
  • nextly's full SQLite integration suite, run on 95cfddac3 + this change: 1,654 passed, 1 failed — bulk-update-override-access › writes a field whose own rule refuses the caller when elevated, which main's own SQLite leg fails identically at 95cfddac3 (the unmodified control; job 103352224752). It is the other half of feat(adapters): the transactional update writes the physical table, as the insert does #1787's fallout — the tx path now bumps updated_at, so a patch whose only field is stripped is no longer empty — and the wt-forms lane fixed it on main in test(nextly): an un-elevated batch row with its only field stripped is a no-op #1806; merged in here, that file passes 4/4.
  • Why both halves matter: main's pg/mysql legs stop at the adapter twins before reaching nextly's suite, so they stay red until this lands even with test(nextly): an un-elevated batch row with its only field stripped is a no-op #1806 in.
  • The pg/mysql twins are the real oracle and run only in CI: read Integration (postgres) and Integration (mysql) by name on this head.

One changeset (all 25 packages, patch).

…ialect

handleQueryError attached its context only when the message did not already
contain the operation's name. Drizzle spells its statements in lower case and,
on PostgreSQL and MySQL, wraps a driver error as 'Failed query: <sql>', so an
update, insert or delete there - or any table or column whose name contains the
word - arrived without it. The check now asks for the context the method
writes, which also keeps a re-handled error from stacking it.

This is what turned main's Integration (postgres) and (mysql) legs red: the
transactional update twins added in #1787 assert the context, and their table
is named int_txpg_update_table.
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 51010275-5baf-452c-a392-8ee6a0ebbd08

📥 Commits

Reviewing files that changed from the base of the PR and between 746a714 and c42424c.

⛔ Files ignored due to path filters (1)
  • .changeset/a-query-error-names-its-operation-on-every-dialect.md is excluded by !.changeset/**
📒 Files selected for processing (2)
  • packages/adapter-drizzle/src/__tests__/adapter.test.ts
  • packages/adapter-drizzle/src/adapter.ts

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

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-11T18:02:35.466271Z c42424c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mobeenabdullah

Copy link
Copy Markdown
Collaborator Author

@codex review

@github-actions github-actions Bot added type: docs Documentation only scope: db-adapter @nextlyhq/adapter-* packages labels Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR title fails Conventional Commits check

Unknown scope "adapters" found in pull request title "fix(adapters): a query error names its operation and table on every dialect". Scope must match one of: nextly, admin, admin-css, client, ui, adapter-postgres, adapter-mysql, adapter-sqlite, adapter-drizzle, storage-s3, storage-vercel-blob, storage-uploadthing, blocks-engine, blocks-react, builder, plugin-form-builder, plugin-page-builder, plugin-seo, plugin-sdk, create-nextly-app, eslint-config, eslint-plugin, module-specifiers, prettier-config, tsconfig, telemetry, playground, root, ci, docs, deps, release.

Examples of valid titles:

  • feat(admin): add role manager dialog
  • fix(adapter-postgres): handle connection pool exhaustion
  • chore(deps): bump zod to 4.2.0

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: c42424c95e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

Whole-Repository Code Hygiene Summary

Full dead-code, duplication, and complexity report for the PR branch as it stands now. Playground is excluded. Quality gate enforcement on introduced issues is performed by the Changed files job.

🌿 Fallow

Warning

Review needed

⚠️ 73 code issues · ⚠️ 689 clone groups · ⚠️ 1044 health findings

See inline review comments for per-finding details.

Code issues (73)
Category Count
Unused files 2
Unused exports 5
Unused dependencies 19
Unused devDependencies 6
Unresolved imports 2
Unlisted dependencies 1
Circular dependencies 38
Duplication (689 groups · 28845 lines · 4.1%)
Locations Lines Tokens
schemas/_dialect-bundles/mysql.relations.ts:40-134
schemas/_dialect-bundles/postgres.relations.ts:40-134
schemas/_dialect-bundles/sqlite.relations.ts:40-134
95 593
cli/commands/db-sync-demote.ts:70-75
cli/commands/db-sync-promote.ts:38-43
cli/commands/dev-build.ts:100-105
cli/commands/dev-build.ts:179-184
cli/commands/dev-build.ts:299-304
cli/commands/dev-build.ts:411-416
cli/commands/dev-build.ts:552-557
cli/commands/dev-server.ts:575-580
cli/commands/dev-server.ts:840-845
cli/commands/dev-server.ts:1143-1148
cli/commands/migrate-field-groups.ts:110-115
6 70
entries/EntryList/EntryTableSkeleton.tsx:74-98
collection/components/CollectionTableSkeleton.tsx:94-118
field-group/components/FieldGroupTableSkeleton.tsx:90-114
plugins/components/PluginsTableSkeleton.tsx:86-110
singles/components/SinglesTableSkeleton.tsx:77-101
src/components/table-skeleton.tsx:100-124
25 89
collections/config/validate-config.ts:380-433
field-groups/config/validate-field-group.ts:185-238
singles/config/validate-single.ts:190-243
54 152
dispatcher/handlers/collection-dispatcher.ts:925-967
field-groups/services/field-group-table-provisioning.ts:186-236
singles/services/reconcile-single-companion.ts:110-160
51 149

… and 684 more groups.

Across 422 files.

Complexity (1044 functions above threshold)
File Function Severity Cyclomatic Cognitive CRAP Lines
singles/services/single-mutation-service.ts:981 <arrow> critical 251 ! 324 ! 13859.2 ! 1625
collections/services/collection-mutation-service.ts:6262 <arrow> critical 175 ! 178 ! 6790 ! 1288
src/init/reload-config.ts:1319 applyReload critical 144 ! 228 ! 4623 ! 1433
shared/lib/entry-validation.ts:223 validateFieldValue critical 109 ! 157 ! 2675.3 ! 432
blocks-engine/src/measure-bytes.ts:646 surveyDocument critical 102 ! 250 ! 137.1 ! 658

5030 files, 77209 functions analyzed (thresholds: cyclomatic > 20, cognitive > 15, CRAP >= 30)

Codebase health

Metric Value
Maintainability 91.7 / 100
Avg complexity 1.8

Tip

Run fallow fix --dry-run to preview auto-fixes.
Add /** @public */ above exports to preserve them.

@pkg-pr-new

pkg-pr-new Bot commented Sep 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nextlyhq/adapter-drizzle

npm i https://pkg.pr.new/@nextlyhq/adapter-drizzle@c42424c

@nextlyhq/adapter-mysql

npm i https://pkg.pr.new/@nextlyhq/adapter-mysql@c42424c

@nextlyhq/adapter-postgres

npm i https://pkg.pr.new/@nextlyhq/adapter-postgres@c42424c

@nextlyhq/adapter-sqlite

npm i https://pkg.pr.new/@nextlyhq/adapter-sqlite@c42424c

@nextlyhq/admin

npm i https://pkg.pr.new/@nextlyhq/admin@c42424c

@nextlyhq/admin-css

npm i https://pkg.pr.new/@nextlyhq/admin-css@c42424c

@nextlyhq/blocks-engine

npm i https://pkg.pr.new/@nextlyhq/blocks-engine@c42424c

@nextlyhq/blocks-react

npm i https://pkg.pr.new/@nextlyhq/blocks-react@c42424c

@nextlyhq/builder

npm i https://pkg.pr.new/@nextlyhq/builder@c42424c

create-nextly-app

npm i https://pkg.pr.new/create-nextly-app@c42424c

@nextlyhq/eslint-plugin

npm i https://pkg.pr.new/@nextlyhq/eslint-plugin@c42424c

nextly

npm i https://pkg.pr.new/nextly@c42424c

@nextlyhq/plugin-form-builder

npm i https://pkg.pr.new/@nextlyhq/plugin-form-builder@c42424c

@nextlyhq/plugin-page-builder

npm i https://pkg.pr.new/@nextlyhq/plugin-page-builder@c42424c

@nextlyhq/plugin-sdk

npm i https://pkg.pr.new/@nextlyhq/plugin-sdk@c42424c

@nextlyhq/plugin-seo

npm i https://pkg.pr.new/@nextlyhq/plugin-seo@c42424c

@nextlyhq/storage-s3

npm i https://pkg.pr.new/@nextlyhq/storage-s3@c42424c

@nextlyhq/storage-uploadthing

npm i https://pkg.pr.new/@nextlyhq/storage-uploadthing@c42424c

@nextlyhq/storage-vercel-blob

npm i https://pkg.pr.new/@nextlyhq/storage-vercel-blob@c42424c

@nextlyhq/ui

npm i https://pkg.pr.new/@nextlyhq/ui@c42424c

commit: c42424c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: db-adapter @nextlyhq/adapter-* packages type: docs Documentation only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant