Skip to content

fix(database): skip undefined relational filter values under drizzle-orm rc - #1789

Merged
viethung0o0 merged 1 commit into
mainfrom
fix/drizzle-undefined-where
Nov 26, 2026
Merged

viethung0o0 merged 1 commit into
mainfrom
fix/drizzle-undefined-where

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

Summary

Production incident: opening Flows fails with
Unexpected 'undefined' in filter value. Use 'EmptyFilter' if you want the filter field to be skipped.

  • Cause: chore(database): upgrade drizzle-orm and drizzle-kit to 1.0.0-rc.5 #1759 upgraded drizzle-orm from 1.0.0-beta.22 to 1.0.0-rc.6. The rc throws on any undefined value in a relational where (top level or inside with), where beta skipped it. flowRepository.buildWhere leaves optional filters (folderId, name, active, enableInInbox) as undefined, so listWithVersions → tx.query.flowModel.findMany({ where }) throws whenever the list is opened without those filters. chore(database): upgrade drizzle-orm and drizzle-kit to 1.0.0-rc.5 #1759 had already wrapped relationsFilterToSQL (used by count) but not db.query.*.
  • Fix: packages/database/src/client.ts wraps findMany/findFirst on the shared relational query builder prototype so each call's config goes through stripUndefined from relations-filter.ts. This restores beta behaviour for every db.query.* and tx.query.* call, not only Flows, since other repositories build where objects the same way. stripUndefined only walks plain objects and arrays; SQL, Date, Placeholder and function values are left untouched.

Test plan

  • New packages/database/__tests__/relational-query-undefined.test.ts: 3 of its 4 tests fail with the production error before the fix and pass after it
  • @chatbotx.io/database test suite: 2187 passed, 942 skipped (DB-only)
  • pnpm lint and pre-commit check-types (26/26 packages) pass
  • Independent review by Codex: no issues found
  • After deploy: open Flows in production with no filters and confirm the list loads

…orm rc

drizzle-orm 1.0.0-rc throws "Unexpected 'undefined' in filter value" for
any undefined key in a relational `where` (top level or inside `with`);
beta-22 skipped them. Repositories such as flow `buildWhere` leave optional
filters undefined, so opening Flows failed in production after #1759.

Patch the shared relational query builder's findMany/findFirst to strip
undefined values from the config, covering every db.query.* and tx.query.*
call, and add a regression test.
@github-actions github-actions Bot added the bug Something isn't working as expected label Nov 26, 2026
@viethung0o0
viethung0o0 merged commit 0def763 into main Nov 26, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants