From edb88510326f2ca0311b3a69815529619e4fd64e Mon Sep 17 00:00:00 2001 From: cheese-cakee Date: Sat, 16 May 2026 01:32:36 +0530 Subject: [PATCH] test_s3: fix test_bucket_logging_request_id for newer botocore The test was using a boto3 event handler to capture the x-amz-request-id header, incorrectly accessing kwargs["response"] in an after-call event. Botocore's after-call event does not pass a "response" kwarg; it passes "parsed", "http_response", "model", and "context". Fix by reading the request ID directly from the put_object() response, which is simpler and works across all botocore versions. Fixes: https://tracker.ceph.com/issues/76587 Signed-off-by: cheese-cakee --- s3tests/functional/test_s3.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 8f1ecfb25..2f20ad750 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -15748,14 +15748,9 @@ def test_bucket_logging_request_id(): assert response['ResponseMetadata']['HTTPStatusCode'] == 200 # capture x-amz-request-id from the put_object response - request_id = None - def capture_request_id(**kwargs): - nonlocal request_id - request_id = kwargs['response']['ResponseMetadata']['HTTPHeaders'].get('x-amz-request-id') - client.meta.events.register('after-call.s3.PutObject', capture_request_id) - - client.put_object(Bucket=src_bucket_name, Key=key, Body=randcontent()) - assert request_id is not None, 'failed to capture x-amz-request-id from response' + response = client.put_object(Bucket=src_bucket_name, Key=key, Body=randcontent()) + request_id = response['ResponseMetadata']['HTTPHeaders'].get('x-amz-request-id') + assert request_id is not None, 'failed to read x-amz-request-id from response headers' _flush_logs(client, src_bucket_name) response = client.list_objects_v2(Bucket=log_bucket_name)