Commit f3795dd
fix: address review — request_id on shape-guard, target_url dedup, retry/index hardening
6 items.
### Load-bearing
1. **`request_id` propagated to shape-guard ValidationError.**
Operators debugging "unexpected response" tickets need the
server-side correlation ID on the *error* path too, not just
the success/passthrough returns. Added an optional
`request_id` parameter to `unexpectedResponseError` and
threaded `envelope.meta?.request_id` through every
shape-guard branch in `validateBatchCreateResponse`. New
regression test asserts the requestId surfaces on
ValidationError.
### Correctness
2. **De-duplicated target_url validation.**
`requireValidTargetUrl` and `requireMaxLength(target_url, ...)`
both ran under `collect()`, both ran their own typeof guard,
and a non-string target_url produced two "must be a string"
messages in the aggregated detail. Inlined the length check
into `requireValidTargetUrl` (priority order: type → scheme
→ length, fail-fast within the field). The collect-all loop
in validateCreateInput is unchanged at the field level.
3. **`batchItemResultValidationReason` index check tightened.**
Was `typeof e.index !== "number"`, which let NaN, Infinity,
negatives, and floats through. `Number.isInteger(...) && ... >= 0`
matches the same posture used by the count integer guards on
the surrounding shape guard.
4. **`parseRetryAfter` rejects trailing garbage.**
`parseInt("60abc", 10)` returns 60 — the SDK would have
silently honored a malformed Retry-After header. Added a
digit-only regex pre-check so any deviation surfaces via the
existing debug log instead. New test asserts a 429 with a
`60abc` header produces an error with `.retryAfter ===
undefined` and the debug log fires.
### JSDoc / clarity
5. **`mapQurlsField`: explained why `"qurls" in raw` (not
truthy)** — empty array `qurls: []` is truthy as a value
but the rename must still happen so consumers see
`access_tokens: []`. Locked in by the existing test.
6. **`MintInput`: explained why mutual-exclusion stays
runtime-only** — `ExtendInput` requires *exactly one* of two
fields (clean `T1 | T2`); `MintInput` allows *at most one*
(zero is valid; server applies 24h default), which would need
a noisier three-arm union. Runtime check catches "both
provided" at minimal cost.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 5b0e51f commit f3795dd
3 files changed
Lines changed: 136 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2020 | 2020 | | |
2021 | 2021 | | |
2022 | 2022 | | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
2023 | 2073 | | |
2024 | 2074 | | |
2025 | 2075 | | |
| |||
4027 | 4077 | | |
4028 | 4078 | | |
4029 | 4079 | | |
| 4080 | + | |
| 4081 | + | |
| 4082 | + | |
| 4083 | + | |
| 4084 | + | |
| 4085 | + | |
| 4086 | + | |
| 4087 | + | |
| 4088 | + | |
| 4089 | + | |
| 4090 | + | |
| 4091 | + | |
| 4092 | + | |
| 4093 | + | |
| 4094 | + | |
| 4095 | + | |
| 4096 | + | |
| 4097 | + | |
| 4098 | + | |
| 4099 | + | |
| 4100 | + | |
| 4101 | + | |
| 4102 | + | |
4030 | 4103 | | |
4031 | 4104 | | |
4032 | 4105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
136 | 141 | | |
137 | | - | |
| 142 | + | |
138 | 143 | | |
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
142 | 147 | | |
| 148 | + | |
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
| |||
250 | 256 | | |
251 | 257 | | |
252 | 258 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
261 | 266 | | |
262 | 267 | | |
263 | 268 | | |
| |||
269 | 274 | | |
270 | 275 | | |
271 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
272 | 282 | | |
273 | 283 | | |
274 | 284 | | |
| |||
290 | 300 | | |
291 | 301 | | |
292 | 302 | | |
293 | | - | |
294 | 303 | | |
295 | 304 | | |
296 | 305 | | |
| |||
335 | 344 | | |
336 | 345 | | |
337 | 346 | | |
338 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
339 | 355 | | |
340 | 356 | | |
341 | 357 | | |
| |||
506 | 522 | | |
507 | 523 | | |
508 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
509 | 535 | | |
510 | 536 | | |
511 | 537 | | |
| |||
554 | 580 | | |
555 | 581 | | |
556 | 582 | | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
557 | 590 | | |
558 | 591 | | |
559 | 592 | | |
| |||
570 | 603 | | |
571 | 604 | | |
572 | 605 | | |
| 606 | + | |
573 | 607 | | |
574 | 608 | | |
575 | 609 | | |
| |||
578 | 612 | | |
579 | 613 | | |
580 | 614 | | |
| 615 | + | |
581 | 616 | | |
582 | 617 | | |
583 | 618 | | |
| |||
588 | 623 | | |
589 | 624 | | |
590 | 625 | | |
| 626 | + | |
591 | 627 | | |
592 | 628 | | |
593 | 629 | | |
| |||
1206 | 1242 | | |
1207 | 1243 | | |
1208 | 1244 | | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
1214 | 1251 | | |
1215 | 1252 | | |
1216 | 1253 | | |
1217 | 1254 | | |
1218 | 1255 | | |
1219 | | - | |
| 1256 | + | |
1220 | 1257 | | |
1221 | 1258 | | |
1222 | 1259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
213 | 222 | | |
214 | 223 | | |
215 | 224 | | |
| |||
0 commit comments