fix: auto-detect GCS endpoint for correct V4 signature config#635
Merged
Conversation
added 3 commits
May 30, 2026 03:26
GCS S3-compatible API requires: - virtual-hosted-style addressing (not path-style) - region_name='auto' for V4 signatures Previously both clients were hardcoded to path-style addressing and used the raw S3_REGION value (often empty), causing SignatureDoesNotMatch on every put_object. Now _boto_config() auto-detects storage.googleapis.com and applies the correct settings, while MinIO and other S3 backends keep path-style addressing unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GCS S3-compatible API continues to reject put_object with SignatureDoesNotMatch even after setting ContentType explicitly.
Root Cause
The boto3/aiobotocore clients were hardcoded to:
addressing_style: "path"— GCS S3 API requiresvirtual-hosted-styleregion_name: used rawS3_REGIONenv var (often empty) — GCS requires"auto"for V4 signaturesWith path-style addressing, GCS computes the signature over a different canonical request than what boto3 signs, causing an unrecoverable mismatch.
Fix
_boto_config()method used by both sync and async clientsstorage.googleapis.comin endpoint URL via_is_gcs()addressing_style=virtual,region_name=autopathstyle, user-specified region)Verification
Existing test
test_s3_backend_passes_max_pool_connectionspasses. The test creates a mock S3Backend — GCS detection is endpoint-based and only activates whenstorage.googleapis.comappears in the URL.