Skip to content

test(aws): Make integration test cassettes AWS region agnostic#1156

Open
Michael Chin (michaelnchin) wants to merge 1 commit into
langchain-ai:mainfrom
michaelnchin:fix/vcr-region-agnostic-cassettes
Open

test(aws): Make integration test cassettes AWS region agnostic#1156
Michael Chin (michaelnchin) wants to merge 1 commit into
langchain-ai:mainfrom
michaelnchin:fix/vcr-region-agnostic-cassettes

Conversation

@michaelnchin

@michaelnchin Michael Chin (michaelnchin) commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Fixing some cassette errors seen in live integ test runs following the updates in #1154:

E               vcr.errors.CannotOverwriteExistingCassetteException: Can't overwrite existing cassette ('tests/cassettes/test_thinking[v0].yaml.gz') in your current record mode (<RecordMode.ONCE: 'once'>).
E               No match for the request (<Request (POST) https://bedrock-runtime.***.amazonaws.com/model/us.anthropic.claude-sonnet-5/converse-stream>) was found.
E               Found 1 similar requests with 1 different matcher(s) :
E               
E               1 - (<Request (POST) https://bedrock-runtime.us-west-2.amazonaws.com/model/us.anthropic.claude-sonnet-5/converse-stream>).
E               Matchers succeeded : ['method', 'body']
E               Matchers failed :
E               uri - assertion failure :
E               https://bedrock-runtime.***.amazonaws.com/model/us.anthropic.claude-sonnet-5/converse-stream != https://bedrock-runtime.us-west-2.amazonaws.com/model/us.anthropic.claude-sonnet-5/converse-stream

Basically, the new cassettes for the revised tests with Sonnet 5 were recorded from my local runs on us-west-2, while the CI actually runs on a different region (that's obfuscated by the AWS_REGION secret). VCR's default matcher requires the endpoint URIs to match exactly, so the replays fail.

To fix this, I've loosened the URI check by replacing VCR's default matcher with a custom region_agnostic_uri matcher, stripping the region ID from the host before performing the comparison.

This has two advantages:

  • It allows future cassettes to be recorded from any region.
  • We can easily move integ CI to a different AWS_REGION without having to update the cassettes to do so.

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.

1 participant