Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disallowing writes only when fully matched request is in cassette #659

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

miki725
Copy link

@miki725 miki725 commented Sep 27, 2022

cassette.filter_request only filters some request attributes like headers but does not take into account any of the match_on configurations. As a result if a similar request has been seen before but does not fully match as per match_on, writes will be disallowed. cassette.__contains__ however fully takes into account all match_on matchers and therefore will only guard against recording to the cassette when the same request has been previously recorded

`cassette.filter_request` only filters some request attributes like
headers but does not take into account any of the `match_on`
configurations. As a result if a similar request has been seen before
but does not fully match as per `match_on`, writes will be disallowed.
`cassette.__contains__` however fully takes into account all `match_on`
matchers and therefore will only guard against recording to the cassette
when the same request has been previously recorded
@miki725
Copy link
Author

miki725 commented Sep 28, 2022

if this looks reasonable I can work on adjusting/adding tests as necessary but would appreciate any feedback first

assuming:

* any of the ignore requests is configured as documented in
  https://vcrpy.readthedocs.io/en/latest/advanced.html?highlight=ignore_hosts#ignore-requests

* request matchers are configured as documented in
  https://vcrpy.readthedocs.io/en/latest/configuration.html#request-matching

since the filtering logic returns None when request should be ignored
however matchers assume both requests being compared are valid
requests and so when one of the requests is None
it raises AttributeError as no attribute such as "uri"
can be accessed on NoneType

this fix simply does not consider the request for matching
if it is ignored
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant