Skip to content

Commit ba04a83

Browse files
authored
fix(vcr): properly check vcr cassette path for aws signature recalculation (#247)
* fix * rel note * fix rel note formatting
1 parent 70f8cf9 commit ba04a83

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ddapm_test_agent/vcr_proxy.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ async def proxy_request(request: Request, vcr_cassettes_directory: str) -> Respo
167167

168168
vcr_cassette_prefix = request.pop("vcr_cassette_prefix", None)
169169
cassette_name = generate_cassette_name(path, request.method, body_bytes, vcr_cassette_prefix)
170+
cassette_file_name = f"{cassette_name}.yaml"
170171

171172
request_kwargs: Dict[str, Any] = {
172173
"method": request.method,
@@ -178,7 +179,9 @@ async def proxy_request(request: Request, vcr_cassettes_directory: str) -> Respo
178179
"stream": True,
179180
}
180181

181-
if provider in AWS_SERVICES and not os.path.exists(os.path.join(vcr_cassettes_directory, provider, cassette_name)):
182+
if provider in AWS_SERVICES and not os.path.exists(
183+
os.path.join(vcr_cassettes_directory, provider, cassette_file_name)
184+
):
182185
if not AWS_SECRET_ACCESS_KEY:
183186
return Response(
184187
body="AWS_SECRET_ACCESS_KEY environment variable not set for aws signature recalculation",
@@ -192,7 +195,7 @@ async def proxy_request(request: Request, vcr_cassettes_directory: str) -> Respo
192195
auth = AWS4Auth(aws_access_key, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_SERVICES[provider])
193196
request_kwargs["auth"] = auth
194197

195-
with get_vcr(provider, vcr_cassettes_directory).use_cassette(f"{cassette_name}.yaml"):
198+
with get_vcr(provider, vcr_cassettes_directory).use_cassette(cassette_file_name):
196199
provider_response = requests.request(**request_kwargs)
197200

198201
# Extract content type without charset
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
vcr: fixes a bug where the aws signature recalculation would always happen, even if the cassette already existed.

0 commit comments

Comments
 (0)