Skip to content

Commit

Permalink
cmd: fix object lock invalid error codes to match AWS
Browse files Browse the repository at this point in the history
Updates storj/edge#510
Updates storj/edge#511

Change-Id: I50f754983ae6d058b6514fd55df2a9daa25eff18
  • Loading branch information
halkyon authored and Storj Robot committed Nov 26, 2024
1 parent 6ed52de commit 0039fe4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cmd/api-errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,13 @@ var errorCodes = errorCodeMap{
HTTPStatusCode: http.StatusBadRequest,
},
ErrPastObjectLockRetainDate: {
Code: "InvalidRequest",
Description: "the retain until date must be in the future",
Code: "InvalidArgument",
Description: "The retain until date must be in the future",
HTTPStatusCode: http.StatusBadRequest,
},
ErrUnknownWORMModeDirective: {
Code: "InvalidRequest",
Description: "unknown wormMode directive",
Code: "InvalidArgument",
Description: "Unknown wormMode directive",
HTTPStatusCode: http.StatusBadRequest,
},
ErrObjectLockInvalidHeaders: {
Expand Down
4 changes: 1 addition & 3 deletions cmd/object-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3134,9 +3134,7 @@ func (api ObjectAPIHandlers) PutObjectRetentionHandler(w http.ResponseWriter, r

objRetention, err := objectlock.ParseObjectRetention(r.Body)
if err != nil {
apiErr := errorCodes.ToAPIErr(ErrMalformedXML)
apiErr.Description = err.Error()
WriteErrorResponse(ctx, w, apiErr, r.URL, guessIsBrowserReq(r))
WriteErrorResponse(ctx, w, ToAPIError(ctx, err), r.URL, guessIsBrowserReq(r))
return
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/bucket/object/lock/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func ParseObjectRetention(reader io.Reader) (*ObjectRetention, error) {
return nil, err
}
if ret.Mode != "" && !ret.Mode.Valid() {
return &ret, ErrUnknownWORMModeDirective
return &ret, ErrMalformedXML
}

if ret.Mode.Valid() && ret.RetainUntilDate.IsZero() {
Expand Down

0 comments on commit 0039fe4

Please sign in to comment.