promplate / partial-json-parser

Parse partial JSON generated by LLM
https://promplate.dev/partial-json-parser
43 stars 1 forks source link

False positive filtering can't handle multiple escapes #10

Closed CNSeniorious000 closed 5 months ago

CNSeniorious000 commented 5 months ago

Initially found in this action run:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/runner/work/partial-json-parser/partial-json-parser/tests/test_hypotheses.py", line 42, in main
    test_partial_json()
  File "/home/runner/work/partial-json-parser/partial-json-parser/tests/test_hypotheses.py", line 28, in test_partial_json
    @given(json)
  File "/home/runner/work/partial-json-parser/partial-json-parser/.venv/lib/pypy3.10/site-packages/hypothesis/core.py", line 1[38](https://github.com/promplate/partial-json-parser/actions/runs/9068091043/job/25283963309#step:5:39)9, in wrapped_test
    raise the_error_hypothesis_found
  File "/home/runner/work/partial-json-parser/partial-json-parser/tests/test_hypotheses.py", line 34, in test_partial_json
    parse_json(json_string[:i])
  File "/home/runner/work/partial-json-parser/partial-json-parser/src/partial_json_parser/core/api.py", line 15, in parse_json
    return parser(ensure_json(json_string, allow_partial, use_fast_fix))
  File "/opt/hostedtoolcache/PyPy/3.10.14/x64/lib/pypy3.10/json/__init__.py", line 352, in loads
    return (_pypyjson.loads(s, JSONDecodeError)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 1 (char 0)
Falsifying example: test_partial_json(
    anything='\\U\x1f',
)

You can reproduce this example by temporarily adding @reproduce_failure('6.79.4', b'AAADAQBcAQAlAQA7AA==') as a decorator on your test case
CNSeniorious000 commented 5 months ago

Fixed in #11