vcrpy icon indicating copy to clipboard operation
vcrpy copied to clipboard

Undocumented 599 (could not replay request) status in aiohttp and tornado

Open vjpr opened this issue 5 years ago • 2 comments
trafficstars

Just ran into an issue where I was receiving 599 status code.

Digging into the source revealed it means No match for the request {!r} was found. Can't overwrite existing cassette {!r} in your current record mode {!r}..

I couldn't see the helpful error message because I was testing a 3rd party api call deep in my e2e tests.

Would be useful to document this.

vjpr avatar May 01 '20 22:05 vjpr

        if cassette.write_protected and cassette.filter_request(vcr_request):
            response = MockClientResponse(method, URL(url))
            response.status = 599
            msg = (
                "No match for the request {!r} was found. Can't overwrite "
                "existing cassette {!r} in your current record mode {!r}."
            )
            msg = msg.format(vcr_request, cassette._path, cassette.record_mode)
            response._body = msg.encode()
            response.close()
            return response

This error should be send to the logger at least.

vjpr avatar May 01 '20 22:05 vjpr

Would be nice to pass the cassette to before_record_request. This way we could access can replay and do our own logging.

vjpr avatar May 01 '20 23:05 vjpr