Repository navigation
feat(matchers): add ignore_order option to json_params_matcher (#756) - #839
mayureshsonawane17 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 603ce1d. Configure here.
| elif ignore_order: | ||
| valid = _compare_json(json_params, json_body, ignore_order=True) | ||
| else: | ||
| valid = json_params == json_body |
There was a problem hiding this comment.
Inverted empty-body matching condition
Medium Severity
Refactoring the match condition inverted the None check. json_params_matcher with params=None no longer accepts an empty JSON object body, and params={} now matches a missing request body. Both differ from the previous request_body is None short-circuit.
Reviewed by Cursor Bugbot for commit 603ce1d. Configure here.


Summary
Fixes #756.
This PR introduces an optional
ignore_order: bool = Falseparameter tomatchers.json_params_matcher(). Whenignore_order=True, elements within JSON lists/arrays (both top-level and nested) are matched without regard to ordering, using recursive multiset equality.Key Changes
_compare_jsonhelper inresponses/matchers.pysupporting order-insensitive list comparison.ignore_order: bool = Falseargument tojson_params_matcherwith full backwards compatibility.responses/tests/test_matchers.pyfor reordered lists, nested dictionary structures, duplicate elements, and length mismatches.README.rstwith documentation and an example ofignore_order=Trueusage.Test Plan
pytest responses/tests/test_matchers.py(57 passed).pytest responses/tests/(254 passed cleanly).