[#673] Correct s3 error code

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2025-04-01 14:59:11 +03:00
parent 7626b6a04a
commit 091ec716d9
2 changed files with 18 additions and 1 deletions

View file

@ -251,7 +251,7 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re
if obj.Error != nil { if obj.Error != nil {
errorObjects = append(errorObjects, formObjNameToLog(obj)) errorObjects = append(errorObjects, formObjNameToLog(obj))
code := "BadRequest" code := "BadRequest"
if s3err, ok := obj.Error.(errors.Error); ok { if s3err, ok := errors.TransformToS3Error(obj.Error).(errors.Error); ok {
code = s3err.Code code = s3err.Code
} }
response.Errors = append(response.Errors, DeleteError{ response.Errors = append(response.Errors, DeleteError{

View file

@ -15,6 +15,7 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data"
apierr "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/errors" apierr "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/errors"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer/encryption" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer/encryption"
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer/frostfs"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
"github.com/pquerna/otp" "github.com/pquerna/otp"
@ -143,6 +144,22 @@ func TestDeleteMultipleObjectCheckUniqueness(t *testing.T) {
require.Len(t, resp.DeletedObjects, 1) require.Len(t, resp.DeletedObjects, 1)
} }
func TestDeleteMultipleObjectCheckS3Error(t *testing.T) {
hc := prepareHandlerContext(t)
bktName, objName := "bucket", "object"
createTestBucket(hc, bktName)
putObject(hc, bktName, objName)
hc.tp.SetObjectError(addrFromObject(hc.tp.Objects()[0]), frostfs.ErrAccessDenied)
resp := deleteObjects(t, hc, bktName, [][2]string{{objName, emptyVersion}})
require.Empty(t, resp.DeletedObjects)
require.Len(t, resp.Errors, 1)
require.Equal(t, "AccessDenied", resp.Errors[0].Code)
}
func TestDeleteObjectsError(t *testing.T) { func TestDeleteObjectsError(t *testing.T) {
hc := prepareHandlerContext(t) hc := prepareHandlerContext(t)