From 5a12bc3916f5f0471f99f7e9c856c753b7b34f62 Mon Sep 17 00:00:00 2001 From: Stany MARCEL Date: Wed, 20 May 2026 09:09:20 +0200 Subject: [PATCH] fix(s3): omit empty x-amz-tagging header for B2 compatibility PutObject unconditionally set Tagging on the SDK input, causing the AWS SDK to emit an empty x-amz-tagging header. Backblaze B2 (and other non-AWS S3-compatible backends) reject any presence of the header, breaking PUTs through the proxy. Only forward Tagging when the client supplied a non-empty value. Closes #34 Co-Authored-By: Claude Opus 4.7 (1M context) --- s3proxy/internal/s3/s3.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/s3proxy/internal/s3/s3.go b/s3proxy/internal/s3/s3.go index 3f89967..c6c6cc1 100644 --- a/s3proxy/internal/s3/s3.go +++ b/s3proxy/internal/s3/s3.go @@ -226,11 +226,15 @@ func (c Client) PutObject(ctx context.Context, bucket, key, tags, contentType, o Bucket: &bucket, Key: &key, Body: bytes.NewReader(body), - Tagging: &tags, Metadata: metadata, ContentType: &contentType, ObjectLockLegalHoldStatus: types.ObjectLockLegalHoldStatus(objectLockLegalHoldStatus), } + // Only forward Tagging when the client supplied a non-empty value. Some S3-compatible + // backends (e.g. Backblaze B2) reject any presence of x-amz-tagging, even when empty. + if tags != "" { + putObjectInput.Tagging = &tags + } if sseCustomerAlgorithm != "" { putObjectInput.SSECustomerAlgorithm = &sseCustomerAlgorithm }