-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Gateway wrong error description for copy object #7526
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and for adding a test! I suggest a minor refactor to avoid future confusion
@@ -31,12 +31,12 @@ func (controller *DeleteObject) HandleAbortMultipartUpload(w http.ResponseWriter | |||
mpu, err := o.MultipartTracker.Get(ctx, uploadID) | |||
if err != nil { | |||
o.Log(req).WithError(err).Error("upload id not found in tracker") | |||
_ = o.EncodeError(w, req, err, gatewayerrors.Codes.ToAPIErr(gatewayerrors.ErrNoSuchKey)) | |||
_ = o.EncodeError(w, req, err, gatewayerrors.Codes.ToAPIErr(gatewayerrors.ErrNoSuchKey, nil)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to pass the actual error instead of nil to all of these calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to limit the scope of the current fix to the CopyObject API.
We need to consider a more holistic approach for the actual solution that might require a deeper fix
pkg/gateway/errors/errors.go
Outdated
@@ -176,20 +176,24 @@ const ( | |||
|
|||
type errorCodeMap map[APIErrorCode]APIError | |||
|
|||
func (e errorCodeMap) ToAPIErr(errCode APIErrorCode) APIError { | |||
func (e errorCodeMap) ToAPIErr(errCode APIErrorCode, err error) APIError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a function
func (e errorCodeMap) ToAPIErrWithInternalError(errCode APIErrorCode, err error) APIError {
It could leverage the existing ToAPIErr
func.
That way you won't have dozens of calls to ToAPIErr
with nil
as the err, although an actual error does exist. I also wonder what the next caller to this funciton would do, pass an err
or nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
esti/s3_gateway_test.go
Outdated
//destRepo := createRepositoryByName(ctx, t, destRepoName) | ||
//defer deleteRepositoryIfAskedTo(ctx, destRepoName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good,
what is expected in case non graverler errors, such as validation? can you please add a test, just so we know whats expected
esti/s3_gateway_test.go
Outdated
@@ -2,6 +2,7 @@ package esti | |||
|
|||
import ( | |||
"bytes" | |||
"github.com/treeverse/lakefs/pkg/block" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for applying the fixes!
Closes #7452
Partial fix for the issue.
Fix error description for copy object errors in S3 GW