Commit 2288c34
fix(server): SECURITY DEFINER maintenance functions wrote non-ISO timestamps into JSONB documents
sweep_stale_compute_nodes() and reclaim_expired_compute_leases() wrote
their updatedAt field via to_jsonb(now()::text) / to_jsonb(p_now::text)
-- casting a timestamptz to ::text first captures Postgres's own default
text output ('2026-08-31 13:45:00.123456+00': space-separated, no colon
in the offset), not ISO-8601. Every subsequent read re-parses that same
document through computeNodeSchema/computeResourceRequestSchema, whose
updatedAt field is z.string().datetime({offset:true}) -- strict
ISO-8601 -- so it threw 'Invalid ISO datetime' the moment either
function's output was read back.
This is what postgres-compute-control-store.test.ts's 'the SECURITY
DEFINER maintenance functions actually run' test was hitting in CI --
the one server-job failure left after the last two fixes (missing
contracts build, deadlocking parallel test files). Confirmed by reading
the actual SQL (no local Postgres available to run it against, per the
standing dev-environment constraint) and cross-referencing Postgres's
own documented JSON behavior: to_jsonb() applied directly to a
timestamptz value formats it as real ISO-8601; to_jsonb() applied to
its ::text cast does not. Fixed by dropping the ::text cast at all
three call sites -- now() and p_now are already timestamptz, so
to_jsonb() alone is correct and sufficient.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent 3c1cbe3 commit 2288c34
1 file changed
Lines changed: 15 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
137 | 145 | | |
138 | 146 | | |
139 | 147 | | |
| |||
152 | 160 | | |
153 | 161 | | |
154 | 162 | | |
155 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
156 | 166 | | |
157 | 167 | | |
158 | 168 | | |
159 | 169 | | |
160 | 170 | | |
161 | 171 | | |
162 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
| |||
0 commit comments