pypi / vcrpy
vcrpy
What changed in vcrpy 7 to 9, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
13 breaking2 security14 new APIs and options7 behavior and defaults45 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initvcrpy 942 changes
Breaking changes 6
The filter now filters multipart/form-data request fields; requests are filtered before matching, so cassettes recorded with unfiltered multipart bodies need re-recording when matching on body.
Using use_cassette() without a path as a context manager now raises a clear TypeError; a path may be omitted only when decorating a function.
Runs when a cassette is loaded as well, so the callback should be idempotent.
A missing metadata key raises this error when the record mode does not allow changing the cassette.
The filter now filters request bodies for every HTTP method, not just POST; re-record cassettes with unfiltered PUT, PATCH, or DELETE bodies if matching on body.
Python 3.11 or later is required; on Python 3.10, pip continues installing vcrpy 8.x.
Security 1
Replaces sensitive values with placeholders when cassettes are saved and restores them when loaded, so secrets stay out of cassette files while requests still match.
New APIs and options 9
While recording, a request matching one already recorded gets the recorded response instead of being sent and recorded again.
Opt in to filtering keys in nested objects of JSON request bodies when using filter_post_data_parameters.
Cassette metadata can store values that are not part of an interaction and return the stored value during playback.
Adds a hook that receives each interaction when a cassette is loaded and can return a changed interaction or None to leave it out.
Adds a hook that receives each interaction when a cassette is saved and can return a changed interaction or None to leave it out.
Cassettes expose a new read-only path property.
use_cassette accepts a persister option to use a custom persister for one cassette.
A new reason attribute provides a sturdier value to check than matching the exception message text.
Use this new function to replace body parameters for any HTTP method.
Behavior and default changes 6
Requests through socks5:// and socks5h:// proxies with requests and urllib3 are now recorded and played back when PySocks is installed.
Responses to unrecorded requests are no longer read by vcrpy, allowing their bodies to stream as usual.
Accepts compiled regular expressions that match whole host names.
Cassette paths and cassette_library_dir now accept pathlib.Path and other path-like objects.
ignore_localhost now also ignores the IPv6 localhost address ::1.
The exception message now explains what went wrong, shows how the closest recorded requests differ, and suggests how to fix it.
Fixes and other changes 20
Responses return connections to urllib3 pools after their bodies are read, preventing sessions with pool_block=True from waiting forever across cassette boundaries.
use_cassette() no longer raises ImportError while building patchers with urllib3 1.x, allowing recordings to proceed.
Fixes an AttributeError when requests builds a response from a urllib.request response.
Requests no longer escape a cassette when a force_reset window opened elsewhere is closed late by garbage collection while the cassette is in use.
Filtering post data no longer crashes on iterator request bodies such as generators; like file bodies, they are left unfiltered.
HTTPS requests played back from a cassette no longer open a real connection or perform a TLS handshake in new_episodes mode.
A warning is logged when a cassette file exists but can't be decoded, instead of silently treating it as empty where recording could overwrite it.
Request can now be imported from vcr.
With allow_playback_repeats set, no longer saves an interaction once per playback.
An empty cassette file is recorded like a missing one instead of causing TypeError or JSONDecodeError.
Calling release_conn() on a streamed urllib3 response returns its connection to the pool.
The body matcher no longer crashes on form-urlencoded and XML-RPC requests without a body.
The filter now matches urlencoded parameter names, including names represented with percent-encoding.
Replayed urllib3 responses now have json(), matching urllib3 2.x responses.
Replayed aiohttp responses now expose raw_headers, allowing code that reads them to work on replay.
Replayed urllib3 responses now provide release_conn() for code that releases pooled responses.
The response stream is closed if reading an httpx response fails during recording.
The body matcher no longer crashes when a body does not parse as its declared content type.
urllib3 and requests responses now have HTTPHeaderDict headers, preserving repeated header values.
aiohttp error responses are recorded when raise_for_status is used on the session or request, and replaying them raises as aiohttp does.
vcrpy 836 changes
Breaking changes 6
Recording and replay now use aiohttp's own StreamReader, so streaming reads work correctly and its full API is available.
Re-recording in all mode replaces every previously recorded interaction matching a new one under match_on; with drop_unused_requests=True, the cassette contains only what was just recorded.
File-like or iterator request bodies are forwarded with Content-Length instead of chunked encoding, which some servers reject.
Recording fails fast when a request or response contains a Python object the safe YAML loader cannot read back, rather than writing a cassette that breaks on replay.
Support for Python 3.9 has been dropped.
Support for urllib3 versions below 2 has been dropped.
Security 1
Cassettes are loaded with a safe YAML loader, preventing arbitrary code execution from untrusted cassettes while preserving support for existing cassettes.
New APIs and options 5
vcrpy adds support for niquests.
Builds a YAML serializer that supports custom Python object tags during recording and replay; register it per VCR instance with register_serializer.
Adds support for httpx 2.x.
Makes the request URL available on VCRHTTPResponse.
This new option removes unused interactions from cassettes.
Behavior and default changes 1
VCR.py can decompress Brotli responses when brotli, brotlipy, or brotlicffi is available.
Fixes and other changes 23
Recording aiohttp requests that upload an open file as a form field no longer crashes; the file's contents are recorded and the whole file is still sent.
Recording aiohttp requests whose body is an async generator, such as a streaming upload, no longer fails.
Binary request bodies passed as bytes or bytearray are left untouched, and form segments without an = are no longer mangled.
Python 3.14 and 3.15, including their free-threaded builds, are supported.
Replay no longer crashes on cassettes that store a null reason phrase; the fix also applies to httpx2.
Bare-host URLs now match cassettes that recorded the same URL with a trailing slash; otherwise the matcher remains as strict as before.
Fixes an AttributeError when niquests reuses a pooled connection with urllib3-future 2.25.901 or later.
Fixes stale keep-alive connection reuse across cassettes.
Errors are clearer when a cassette contains an unsupported YAML tag.
Invalid record_mode values are validated and raise a clear error.
Fixes compatibility with aiohttp 3.14.
Uses an explicit type check for the body check.
Accounts for modified requests when storing played cassettes, so drop_unused_requests honours before_record_request filtering.
Improves the error message when a matching request has already been consumed.
Fixed sync requests in async contexts for HTTPX.
Fixes aiohttp allowing both data and json arguments when one is None.
Fixes usage of an io-like interface with VCR.py.
Custom httpx transports are now supported.
Fixes a KeyError for follow_redirects.
Proxy addresses no longer end up in cassette URIs.
Fixes httpx.ResponseNotRead exceptions.
httpx support now patches httpcore instead of httpx.
Fixes the deprecation warning on Python 3.14.
vcrpy 73 changes
Breaking changes 1
Support for Python 3.8 was dropped.
Fixes and other changes 2
A bug involving asyncio.run was fixed.
Fixed a missing version_string issue for urllib2>=2.3.0.