Commit 4a85fcc
Repair elided empty array slots like [1,,2] (0.15.0)
[1,,2] silently mangled to [[1],2] and [1,,,,2] raised. The empty slot
made parse_array terminate early (emitting [1]), then the root
comma-sequence wrap turned [1] and 2 into NDJSON [[1],2] — data
corruption. Both are upstream-shared (jsonrepair v3.14.0 produces the
same mangle / raise).
Drop the elided slots instead: after a separator comma, parse_array now
skips any further commas via a new skip_elided_commas helper, so
[1,,2] -> [1,2], [1,,,,2] -> [1,2], [1, ,2] -> [1,2] (whitespace and
comments between the commas are skipped too). Dropping — rather than
inserting null — matches the existing leading-comma repair ([,1] ->
[1]) and dirty-json. Divergence from upstream, commented at the site.
Arrays only. An elided comma in an object ({"a":1,,"b":2}) still raises
rather than guessing a missing key: it is a clean error with no data to
mangle, so we hold upstream's behavior. Pinned in the spec.
Differential vs main over a 42-input comma grid: every change is an
array with elided commas going from mangle/raise to a correct drop;
objects and all non-elided shapes (leading/trailing commas, ellipsis,
missing commas, truncated nested containers) are unchanged. Bench flat
across all four scenarios. rspec (204 examples, 100% line+branch),
rubocop, rbs validate, steep all green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 91bdbf3 commit 4a85fcc
6 files changed
Lines changed: 59 additions & 2 deletions
File tree
- lib/json
- repair
- sig/json
- spec
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
3 | 20 | | |
4 | 21 | | |
5 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
437 | 453 | | |
438 | 454 | | |
439 | 455 | | |
| |||
857 | 873 | | |
858 | 874 | | |
859 | 875 | | |
| 876 | + | |
| 877 | + | |
860 | 878 | | |
861 | 879 | | |
862 | 880 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
507 | 526 | | |
508 | 527 | | |
509 | 528 | | |
| |||
0 commit comments