Skip to content

Commit

Permalink
private/bucket: fix GetBucketObjectLockConfiguration error handling
Browse files Browse the repository at this point in the history
Fix error handling to correspond to this change
storj/storj@8b607f4#diff-dfebce699056a5f80eb2b5831e46577c37e71e7d0c9f9df1833cbc858622be65R564

Change-Id: I8eaec50505c108a15a7d8f1cfe25ebd004d51ff7
  • Loading branch information
VitaliiShpital committed Aug 6, 2024
1 parent b159dd0 commit 7fd31b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion private/bucket/buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func GetBucketObjectLockConfiguration(ctx context.Context, project *uplink.Proje
Name: []byte(bucketName),
})
if errs2.IsRPC(err, rpcstatus.NotFound) {
if strings.HasSuffix(errs.Unwrap(err).Error(), "no Object Lock configuration") {
if strings.HasPrefix(errs.Unwrap(err).Error(), "Object Lock is not enabled for this") {
err = ErrBucketObjectLockConfigurationNotFound
}
}
Expand Down
2 changes: 1 addition & 1 deletion testsuite/private/bucket/buckets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func TestCreateBucketWithObjectLock(t *testing.T) {
require.NoError(t, err)

_, err = bucket.GetBucketObjectLockConfiguration(ctx, project, "test-bucket")
require.Error(t, err)
require.ErrorIs(t, err, bucket.ErrBucketObjectLockConfigurationNotFound)

_, err = bucket.CreateBucketWithObjectLock(ctx, project, bucket.CreateBucketWithObjectLockParams{
Name: "test-bucket",
Expand Down

0 comments on commit 7fd31b3

Please sign in to comment.