josephburnett / jd

JSON diff and patch
MIT License
826 stars 38 forks source link

Fuzz failure: incorrect diff with nested arrays with set semantics #45

Closed josephburnett closed 2 years ago

josephburnett commented 2 years ago

Fuzzing failure with input:

go test fuzz v1
string("[{},[]]")
string("[{},[{},[]]]")

Incorrect diff with set semantics.

fuzz: elapsed: 52m45s, execs: 44374875 (28974/sec), new interesting: 794 (total: 793)
fuzz: minimizing 63-byte failing input file
fuzz: elapsed: 52m47s, minimizing
--- FAIL: FuzzJd (3167.23s)
    --- FAIL: FuzzJd (0.00s)
        common_test.go:245: applying patch @ [["set"],{}]
            - [{},[]]
            + [{},[]]
             to [{},[]] should give [{},[{},[]]]. Got err: Invalid diff. Expected [[]] at [] but found nothing.

    Failing input written to testdata/fuzz/FuzzJd/61c145c6c646c53946229fb0125821ff47c91b63e87da5709002b4fee8b96ca4
    To re-run:
    go test -run=FuzzJd/61c145c6c646c53946229fb0125821ff47c91b63e87da5709002b4fee8b96ca4
FAIL
exit status 1
FAIL    github.com/josephburnett/jd/lib 3167.249s
josephburnett commented 2 years ago

https://github.com/josephburnett/jd/commit/2caa2262323ac28fd7c7eca27d406641c88707b5 has the regression test

josephburnett commented 2 years ago

Fixed: https://github.com/josephburnett/jd/commit/5048bb6c609bc8c69d8d84b4852c7192f98e5d09