Commit 8616b6b
committed
fix(v2): make the NUL path scan linear, and force a write surface to choose
Two findings from a simplify pass, both in code this branch added.
findNulBytePath copied `[...path, key]` per child, which is O(nodes x depth).
A caller controls that depth directly: v2 row cell values are `z.unknown()`,
so nesting passes Zod untouched and reaches the scan. Measured on Node 22 --
JSON.parse accepts a 200KB body nested 100k deep in 9.8ms, and the scan then
blocked the event loop for 27.7s. Frames now carry a parent link and the path
is materialized once, for the node actually reported: 27.7s -> 5ms, with
byte-identical paths across nested arrays, records, NUL keys and clean input.
The always-run first pass drops Object.entries for Object.keys, which halves
its cost on large bodies by not allocating a pair array per object.
`strictWrite` was optional with the lenient default, so a v2 write route added
tomorrow would silently inherit first-party behavior -- unknown column dropped
under a 201, uncoercible cell stored as null -- defended by nothing but five
copies of a literal. It is now required on the five write-shaped inputs, so
omission is a compile error. The type-checker named every caller: the five v2
routes already passed true, and the three Copilot sites now say false
explicitly, which is the behavior they already had.1 parent 9f693e1 commit 8616b6b
3 files changed
Lines changed: 51 additions & 16 deletions
File tree
- apps/sim/lib
- api/server
- copilot/tools/server/table
- table/application
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
33 | 49 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
37 | 58 | | |
38 | 59 | | |
39 | | - | |
| 60 | + | |
40 | 61 | | |
41 | 62 | | |
42 | 63 | | |
43 | | - | |
| 64 | + | |
44 | 65 | | |
45 | | - | |
| 66 | + | |
46 | 67 | | |
47 | 68 | | |
48 | 69 | | |
49 | 70 | | |
50 | | - | |
| 71 | + | |
51 | 72 | | |
52 | 73 | | |
53 | 74 | | |
54 | 75 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
60 | 81 | | |
61 | 82 | | |
62 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
| |||
327 | 328 | | |
328 | 329 | | |
329 | 330 | | |
| 331 | + | |
330 | 332 | | |
331 | 333 | | |
332 | 334 | | |
| |||
473 | 475 | | |
474 | 476 | | |
475 | 477 | | |
| 478 | + | |
476 | 479 | | |
477 | 480 | | |
478 | 481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
99 | | - | |
| 98 | + | |
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
| |||
419 | 418 | | |
420 | 419 | | |
421 | 420 | | |
| 421 | + | |
| 422 | + | |
422 | 423 | | |
423 | 424 | | |
424 | 425 | | |
| |||
428 | 429 | | |
429 | 430 | | |
430 | 431 | | |
| 432 | + | |
| 433 | + | |
431 | 434 | | |
432 | 435 | | |
433 | 436 | | |
| |||
527 | 530 | | |
528 | 531 | | |
529 | 532 | | |
| 533 | + | |
| 534 | + | |
530 | 535 | | |
531 | 536 | | |
532 | 537 | | |
| |||
735 | 740 | | |
736 | 741 | | |
737 | 742 | | |
| 743 | + | |
| 744 | + | |
738 | 745 | | |
739 | 746 | | |
740 | 747 | | |
| |||
784 | 791 | | |
785 | 792 | | |
786 | 793 | | |
| 794 | + | |
| 795 | + | |
787 | 796 | | |
788 | 797 | | |
789 | 798 | | |
| |||
907 | 916 | | |
908 | 917 | | |
909 | 918 | | |
| 919 | + | |
| 920 | + | |
910 | 921 | | |
911 | 922 | | |
912 | 923 | | |
| |||
0 commit comments