Skip to content
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

Handle no path for delete objects in gateway #1708

Merged
merged 2 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/catalog/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ var (
)

var (
ErrInvalidType = errors.New("invalid type")
ErrRequiredValue = errors.New("required value")
ErrInvalidType = errors.New("invalid type")
ErrRequiredValue = errors.New("required value")
ErrPathRequiredValue = fmt.Errorf("missing path: %w", ErrRequiredValue)
)

type ValidateFunc func(v interface{}) error
Expand Down Expand Up @@ -171,7 +172,7 @@ func ValidatePath(v interface{}) error {
}
l := len(s.String())
if l == 0 {
return ErrRequiredValue
return ErrPathRequiredValue
}
if l > MaxPathLength {
return fmt.Errorf("%w: %d is above maximum length (%d)", ErrInvalidValue, l, MaxPathLength)
Expand Down
5 changes: 5 additions & 0 deletions pkg/gateway/operations/deleteobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func (controller *DeleteObjects) Handle(w http.ResponseWriter, req *http.Request
switch {
case errors.Is(err, catalog.ErrNotFound):
lg.Debug("tried to delete a non-existent object")
case errors.Is(err, catalog.ErrPathRequiredValue):
// issue #1706 - https://github.com/treeverse/lakeFS/issues/1706
// Spark trying to delete the path "main/", which we map to branch "main" with an empty path.
// Spark expects it to succeed (not deleting anything is a success), instead of returning an error.
lg.Debug("tried to delete with an empty branch")
case err != nil:
lg.WithError(err).Error("failed deleting object")
errs = append(errs, serde.DeleteError{
Expand Down