You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
driver-sql (PG): JSON-field values are bound without JSON.stringify — non-empty arrays and bare strings 500, empty array silently stored as {} #10995
bugSomething isn't workingdomain:engineRetired 2026-10-22, alias of domain:server (engine surface); in-flight cards keep it until they landpriority:p0Queue-jump: outranks batch and breaks the round — never exempts claiming or same-file serial
Found live on the cloud control plane (cloud.objectos.ai, Postgres/Neon via driver-sql) while auditing browser console errors. Filed here per contract-first: the mechanism is the driver's, every PG-backed deployment inherits it.
Reproduction matrix — one PATCH, only value changes
sys_user_preference.value is a JSON-typed field. PATCH /api/v1/data/sys_user_preference/:id with:
body value
result
{"a":1} (object)
200
42 (number)
200
{"items":[1,2]} (array nested in object)
200
[{"type":"app",…}] (non-empty array)
500 DATABASE_ERROR
"x" (string)
500 DATABASE_ERROR
[] (empty array)
200 — but silently stored as {} (see mechanism)
POST behaves identically (a create with an array value 500s).
Mechanism (inferred from the signature — verify at the driver)
The matrix is the classic node-postgres fingerprint for passing JSON-field values to the driver without JSON.stringify:
JS object → node-pg serialises to JSON text → valid jsonb ✓
JS array → node-pg converts to a Postgres array literal ({…}) → invalid JSON text → 500; except [], whose literal {} happens to be valid JSON — so an empty array is accepted and silently stored as an empty object. That last row is data corruption, not an error, and it will outlive any fix that only handles the 500s.
JS stringx → passed raw → not valid JSON text ("x" would be) → 500; a numeric string/number passes because 42 is valid JSON.
Expected: the SQL driver's PG path must JSON.stringify every JSON-field binding (insert AND update), exactly as it presumably does for objects via node-pg's default object handling — relying on node-pg's per-type defaults is the bug.
User-visible impact, today, on every control-plane deployment
The Console's "recent items" preference (ui.recent) is naturally a list. Every navigation writes it → every write 500s → a red DATABASE_ERROR in the browser console on every console visit, recents never persist, and the server logs a 5xx per page view. Both prod and staging control planes are PG, so this is not an environment quirk. (Tenant environments on Turso/SQLite take a different driver path, which is presumably why the seed/data suites never caught it.)
Note for the fix
The 500 half needs the stringify; the []→{} half needs a regression test of its own — it is the case that stays wrong silently after the crash is fixed.
Scalar JSON values ("x", true, null) are legal JSON documents and should round-trip; a fix that only handles arrays re-fails the string row of the matrix.
Triage: lands in packages/drivers/driver-sql (PG binding path) ⇒ domain:engine, type Bug, queued pm:queue + priority:p0.
p0 rationale (queue-jump is priority, not exemption — claim protocol and hot-file serial still apply): this is live on every PG-backed deployment today, including both production and staging control planes — every console navigation writes ui.recent (a list) ⇒ every write 500s, a red DATABASE_ERROR per page view, recents never persist, plus the sharper half: [] is silently stored as {} — data corruption that survives any fix addressing only the 500s. Filed by the maintainer from a live-prod audit. The tenant-path Turso/SQLite drivers don't share the path, which is why the suites are blind — that blindness is part of the defect surface.
Dispatch notes for the engine seat:
The mechanism is inferred from the node-postgres fingerprint — the card itself says verify at the driver. Treat "missing JSON.stringify on JSON-field bindings" as a mechanism assumption to confirm before coding, covering insert AND update.
Required regression pins, per the card: (a) non-empty array round-trips, (b) bare string / scalar JSON ("x", true, null) round-trips, (c) [] round-trips as [] not {} — (c) is the one that stays silently wrong otherwise. If no PG is reachable from the dev container, pin at the knex-binding level (assert the bound parameter is JSON text) and say so in the PR.
bugSomething isn't workingdomain:engineRetired 2026-10-22, alias of domain:server (engine surface); in-flight cards keep it until they landpriority:p0Queue-jump: outranks batch and breaks the round — never exempts claiming or same-file serial
Activity
huangyiirene commentedon Aug 22, 2026
Triage: lands in
packages/drivers/driver-sql(PG binding path) ⇒domain:engine, typeBug, queuedpm:queue+priority:p0.p0 rationale (queue-jump is priority, not exemption — claim protocol and hot-file serial still apply): this is live on every PG-backed deployment today, including both production and staging control planes — every console navigation writes
ui.recent(a list) ⇒ every write 500s, a redDATABASE_ERRORper page view, recents never persist, plus the sharper half:[]is silently stored as{}— data corruption that survives any fix addressing only the 500s. Filed by the maintainer from a live-prod audit. The tenant-path Turso/SQLite drivers don't share the path, which is why the suites are blind — that blindness is part of the defect surface.Dispatch notes for the engine seat:
JSON.stringifyon JSON-field bindings" as a mechanism assumption to confirm before coding, covering insert AND update."x",true,null) round-trips, (c)[]round-trips as[]not{}— (c) is the one that stays silently wrong otherwise. If no PG is reachable from the dev container, pin at the knex-binding level (assert the bound parameter is JSON text) and say so in the PR.sql-driver.tscarries A compare-and-setwhereon a by-idupdateis silently inert — the extra predicate keys never reach the driver, andSqlHttpOutbox.redeliver's status guard is one of them #11009/driver-sql: SQLite introspection reports only the FIRST column of a composite primary key (pk === 1vs SQLite's 1,2,3… numbering) #10997 (queued) — p0 does not exempt same-file serial; the seat sequences.Generated by Claude Code
fix(driver-sql,objectql): JSON-field values must not depend on DDL ha…