getsentry / getsentry/responses

Non-strict json_params_matcher raises TypeError on nested object/scalar mismatch

Open Beginner friendly
#814 0 comments 0 reactions 0 assignees View on GitHub
Waiting for: Product Owner
Dominant language
Python
Stars
4.3k
Forks
378
Avg merge
4d 1h
Merged PRs (30d)
1

Description

### Reproduction

```python
from unittest.mock import Mock
from responses import matchers

matcher = matchers.json_params_matcher({"page": 1}, strict_match=False)
matcher(Mock(body='{"page": {"type": "json"}}'))
```

### Current behavior

The matcher raises `TypeError: argument of type 'int' is not a container or iterable`.

`_filter_dict_recursively` recurses whenever the actual value is a dictionary, even if the expected value at the same key is a scalar.

### Expected behavior

This is an ordinary mismatch, so the matcher should return `(False, reason)` instead of raising. Non-strict matching should still recurse when both values are dictionaries.

I have a small fix and regression test ready.

### AI assistance disclosure

OpenAI Codex (GPT-5) assisted with investigation, the reproducer, regression test, implementation, and drafting this report. I reviewed the changes and ran the relevant tests locally.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at _filter_dict_recursively in the JSON parameter matcher and reproduce the nested object/scalar mismatch shown in the issue. Add or update the regression test for non-strict matching, then run the relevant matcher tests. Done means this mismatch returns (False, reason), while recursion still occurs when both values are dictionaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.