harbor run -t openthoughts/tasktrove-swe-rebench-patched-oracle-swe_rebench-02897
harbor download openthoughts/tasktrove-swe-rebench-patched-oracle-swe_rebench-02897
cd /testbed git clone https://github.com/horejsek/python-fastjsonschema.git . && git checkout 4b0d76cb07d78f047813c6bcda01879ee0a0216c git submodule init git submodule update pip install -r /setup_files/requirements.txt pip install -e .[devel] pip install pytest
Incorrect validation of "uniqueItems" While evaluating this library, I noticed that it's incorrectly validating uniqueItems.
uniqueItems
Minimal example:
from fastjsonschema import compile validate = compile({"type": "array", "uniqueItems": "true"}) def print_validity(data): try: validate(data) print("Equal and valid!") except Exception: print("Invalid") d1 = {"foo": 1} d1["bar"] = 2 d2 = {"bar": 2} d2["foo"] = 1 assert d1 == d2 print_validity([1, 1]) print_validity([d1, d2])
This prints
Invalid Equal and valid!
The issue is that str is used to be able to put dicts in a set (as they are not otherwise hashable) in https://github.com/horejsek/python-fastjsonschema/blob/4b0d76cb07d78f047813c6bcda01879ee0a0216c/fastjsonschema/draft04.py#L353 but it's possible for str(d1) != str(d2) when d1 == d2 as the example demonstrates.
str
dict
set
str(d1) != str(d2)
d1 == d2