Skip to content

Commit

Permalink
{cmd,pkg}: fix error codes returned for PutObjectLockConfiguration
Browse files Browse the repository at this point in the history
Updates storj/edge#528

Change-Id: I1d687b68219b8a7e294c98ddafaade6d4d0fad2a
  • Loading branch information
halkyon committed Nov 26, 2024
1 parent 41a5cf9 commit 6ed52de
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 289 deletions.
16 changes: 16 additions & 0 deletions cmd/api-errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const (
ErrInternalError
ErrInvalidAccessKeyID
ErrInvalidArgument
ErrInvalidRetentionPeriod
ErrRetentionPeriodTooLarge
ErrInvalidBucketName
ErrInvalidDigest
ErrInvalidRange
Expand Down Expand Up @@ -501,6 +503,16 @@ var errorCodes = errorCodeMap{
Description: "Invalid argument",
HTTPStatusCode: http.StatusBadRequest,
},
ErrInvalidRetentionPeriod: {
Code: "InvalidArgument",
Description: "Default retention period must be a positive integer value for 'Days' or 'Years'",
HTTPStatusCode: http.StatusBadRequest,
},
ErrRetentionPeriodTooLarge: {
Code: "InvalidArgument",
Description: "Default retention period too large for 'Days' or 'Years'",
HTTPStatusCode: http.StatusBadRequest,
},
ErrInvalidBucketName: {
Code: "InvalidBucketName",
Description: "The specified bucket is not valid.",
Expand Down Expand Up @@ -1850,6 +1862,10 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
apiErr = ErrObjectLockInvalidHeaders
case objectlock.ErrMalformedXML:
apiErr = ErrMalformedXML
case objectlock.ErrInvalidRetentionPeriod:
apiErr = ErrInvalidRetentionPeriod
case objectlock.ErrRetentionPeriodTooLarge:
apiErr = ErrRetentionPeriodTooLarge
}

// Compression errors
Expand Down
Loading

0 comments on commit 6ed52de

Please sign in to comment.