From 8174b32cd7c3573c463c6b05cc5e3aa0c0605b5b Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Wed, 21 Oct 2026 10:31:11 -0400 Subject: [PATCH] docs: document the postgres 100-argument lock limit and drizzle patch --- AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AGENTS.md b/AGENTS.md index f9624418..08a8cb1b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -222,6 +222,7 @@ never to dense data UI, tables, forms, dialogs, buttons, or shadcn-styled surfac - `.npmrc` sets `legacy-peer-deps=true` for dependency resolution compatibility. - `bun run db push` fails with `must be owner of table spatial_ref_sys` (a PostGIS table owned by the DB superuser) — drizzle-kit push does a full-schema diff and trips on it. Workaround: apply the needed `ALTER TABLE` directly (via node + `pg` reading `DATABASE_URI` from `.env`) or use Payload's migration runner (`bun run payload migrate`). - **Payload 3 field-level access never rejects an update request**: when a field's `access` fn returns `false`, Payload silently deletes that field from the incoming data (`node_modules/payload/dist/fields/hooks/beforeValidate/promise.js`) and the save SUCCEEDS with the previous value. No 403, "Updated successfully." toast, other fields still save. It is enforcement without feedback; if you need a loud rejection or hidden dropdown options, that requires a collection `beforeChange` hook or a custom admin field component. +- **Admin edit views throw `54023 cannot pass more than 100 arguments` once the unit approaches 100 collections**: `payload_locked_documents_rels` gains one FK column per collection and Drizzle hydrates the lock's polymorphic relationship with a single `json_build_array(...)`, which Postgres caps at 100 arguments. `drizzle-orm@0.45.2` is bun-patched (`patches/drizzle-orm@0.45.2.patch`) to chunk that call into 100-argument groups joined with `::jsonb ||`; keep the patch (and its `patchedDependencies` entry) when upgrading drizzle, and `tests/int/locked-documents-query.int.spec.ts` fails loudly if it is missing. - **Admin-panel-visible access bugs that contradict passing API tests**: check the actual role permission rows in the DB first, then the field-strip semantics above. The dev DB once had `system:admin-access` hand-granted to division roles (tests build clean roles, so tests pass while the panel misbehaves). The 30s `loadUserPermissions` cache is per-user-id and safe, but remember it exists when editing role data. - PATCHing a document that is open in someone's admin edit tab returns **423 Locked** (Payload document locks). Test with a different document or wait for the lock to clear. - For replaying admin-panel requests from the terminal: `/api/access` returns the caller's resolved permission map (collection `read` results are either a bare boolean like `true` or `{ permission, where }`; handle both shapes), and an officer-grade JWT can be crafted exactly like the impersonation route does (add a session `sid` to the target user, then `jwtSign` with `getFieldsToSign`).