From 506359411af6161274c35a51efa6735f2d2a639b Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 18 Jul 2025 14:56:48 -0700 Subject: [PATCH] Fix S3 compatibility in Workhorse uploads for non-AWS S3 providers GitLab 18.2 updated the `aws-sdk-go-v2/service/s3` from v1.66.0 to v1.80.2 in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/189094. As discussed in https://github.com/aws/aws-sdk-go-v2/issues/3003 and https://github.com/aws/aws-sdk-go-v2/discussions/2960, `github.com/aws/aws-sdk-go-v2/service/s3` v1.73.0 changed the AWS SDK default object integrity behavior. Third-party S3 providers, such as Linode, may fail with `XAmzContentSHA256Mismatch` error as a result. To restore compatibility, configure the client only to do request checksum calculations when required. Changelog: fixed --- workhorse/internal/upload/destination/objectstore/s3_client.go | 1 + .../internal/upload/destination/objectstore/s3_client_test.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/workhorse/internal/upload/destination/objectstore/s3_client.go b/workhorse/internal/upload/destination/objectstore/s3_client.go index ca8e05c5feb2ba..4c7ecc73c2f56a 100644 --- a/workhorse/internal/upload/destination/objectstore/s3_client.go +++ b/workhorse/internal/upload/destination/objectstore/s3_client.go @@ -82,6 +82,7 @@ func setupS3Client(s3Credentials config.S3Credentials, s3Config config.S3Config) o.BaseEndpoint = aws.String(s3Config.Endpoint) } o.UsePathStyle = s3Config.PathStyle + o.RequestChecksumCalculation = aws.RequestChecksumCalculationWhenRequired }) clientCache.clients[s3Config] = &s3Client{ diff --git a/workhorse/internal/upload/destination/objectstore/s3_client_test.go b/workhorse/internal/upload/destination/objectstore/s3_client_test.go index 2d5684dde93b5f..cae656409ed539 100644 --- a/workhorse/internal/upload/destination/objectstore/s3_client_test.go +++ b/workhorse/internal/upload/destination/objectstore/s3_client_test.go @@ -7,6 +7,8 @@ import ( "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab/workhorse/internal/config" + + "github.com/aws/aws-sdk-go-v2/aws" ) func TestS3ClientSetup(t *testing.T) { @@ -22,6 +24,7 @@ func TestS3ClientSetup(t *testing.T) { require.Nil(t, options.BaseEndpoint) require.Equal(t, "us-west-1", options.Region) require.True(t, options.UsePathStyle) + require.Equal(t, aws.RequestChecksumCalculationWhenRequired, options.RequestChecksumCalculation) clientCache.Lock() require.Len(t, clientCache.clients, 1) -- GitLab