Commit 2b09d20
fix(webapp): parse idempotencyKeyOptions in canonical { key, scope } shape on buffer read-fallback
`readFallback.server.ts` was checking `Array.isArray(idempotencyKeyOptionsRaw)` and
returning `undefined` otherwise. The SDK and Prisma both serialise this
field as `{ key, scope }` (per `IdempotencyKeyOptionsSchema`); the
array form never matches, so `SyntheticRun.idempotencyKeyOptions` was
always `undefined` for buffered runs.
Downstream effect: `getUserProvidedIdempotencyKey` falls back to
`run.idempotencyKey` when options are absent — which is the *hash*,
not the user-supplied key. PG-resident runs return the user's key
(options parse succeeds); buffered runs were returning the hash. The
API's `idempotencyKey` field silently flipped values at the drainer-
materialisation boundary.
Parse via `IdempotencyKeyOptionsSchema.safeParse` so the buffered
response matches PG-resident behaviour from the moment the run is
buffered.
Type change is local to `SyntheticRun` — `synthesiseFoundRunFromBuffer`
and `buildSyntheticSpanRun` both forward via `?? null` into Prisma
`JsonValue | null` destinations, which accept the new object shape.
Two regression tests on `mollifierReadFallback.test.ts`:
1. Canonical `{ key, scope }` object parses to the schema-shaped data.
2. Legacy array form (the previous bug) and other invalid shapes
return undefined so downstream falls back to the hash, matching
how PG-resident runs handle malformed/missing options.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c5e3ddb commit 2b09d20
2 files changed
Lines changed: 92 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
| |||
145 | 155 | | |
146 | 156 | | |
147 | 157 | | |
148 | | - | |
149 | | - | |
150 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
151 | 170 | | |
152 | 171 | | |
153 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
198 | 265 | | |
199 | 266 | | |
200 | 267 | | |
| |||
0 commit comments