Skip to content

Commit

Permalink
Merge pull request #680 from snowflakedb/ignore405ForGetBucketAcceler…
Browse files Browse the repository at this point in the history
…ateConfiguration

Ignore 405 error when S3 Acceleration is disabled on the S3 bucket
  • Loading branch information
sfc-gh-ext-simba-lb authored Nov 2, 2022
2 parents 2d19081 + 04cc575 commit a2529a2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions file_transfer_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ func (sfa *snowflakeFileTransferAgent) transferAccelerateConfig() error {
if errors.As(err, &ae) {
if ae.ErrorCode() == "AccessDenied" {
return nil
} else if ae.ErrorCode() == "MethodNotAllowed" {
return nil
}
}
return err
Expand Down
44 changes: 44 additions & 0 deletions file_transfer_agent_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) 2022 Snowflake Computing Inc. All rights reserved.

package gosnowflake

import (
"context"
"errors"
"testing"

"github.com/aws/smithy-go"
)

func TestGetBucketAccelerateConfiguration(t *testing.T) {
if runningOnGithubAction() {
t.Skip("Should be run against an account in AWS EU North1 region.")
}
config, err := ParseDSN(dsn)
if err != nil {
t.Error(err)
}
sc, err := buildSnowflakeConn(context.Background(), *config)
if err != nil {
t.Fatal(err)
}
if err = authenticateWithConfig(sc); err != nil {
t.Fatal(err)
}
sfa := &snowflakeFileTransferAgent{
sc: sc,
commandType: uploadCommand,
srcFiles: make([]string, 0),
data: &execResponseData{
SrcLocations: make([]string, 0),
},
}
if err = sfa.transferAccelerateConfig(); err != nil {
var ae smithy.APIError
if errors.As(err, &ae) {
if ae.ErrorCode() == "MethodNotAllowed" {
t.Fatalf("should have ignored 405 error: %v", err)
}
}
}
}

0 comments on commit a2529a2

Please sign in to comment.