-
Notifications
You must be signed in to change notification settings - Fork 360
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
Add conflict response and use it when creating an existing resource #1900
Conversation
@itaiad200 you're checking in the |
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.
Please remove webui/build
and fix auth/service
- Other than that, looks good! :)
pkg/db/tx.go
Outdated
@@ -121,6 +121,9 @@ func (d *dbTx) Exec(query string, args ...interface{}) (pgconn.CommandTag, error | |||
"query": queryToString(query), | |||
"took": time.Since(start), | |||
}) | |||
if IsUniqueViolation(err) { |
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.
This breaks pkg/auth/service.go
- there are several places that check for db.IsUniqueViolation(..)
- Having a good error value is indeed better but please fix the auth service to check for this error instead..
Better yet, make this check unexported to make sure no-one else is relying on it.
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.
pkg/api/controller.go
Outdated
@@ -1515,6 +1504,11 @@ func handleAPIError(w http.ResponseWriter, err error) bool { | |||
errors.Is(err, model.ErrValidationError): | |||
writeError(w, http.StatusBadRequest, err) | |||
|
|||
case errors.Is(err, graveler.ErrBranchExists), | |||
errors.Is(err, graveler.ErrTagAlreadyExists), | |||
errors.Is(err, graveler.ErrNotUnique): |
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.
Might be more readable if ErrBranchExists
and ErrTagAlreadyExists
were both wrapping graveler.ErrNotUnique
- could make this check a little more generic.
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.
if err != nil { | ||
if errors.Is(err, db.ErrAlreadyExists) { | ||
return nil, graveler.ErrNotUnique |
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 rely on graveler to now return ErrAlreadyExists for these methods - I think the interface should document that (i.e. an implementation of it is now expected to return this error for duplicate repos, branches, tags).
Go makes this pretty hard to express in code, so let's at least document it.
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.
@@ -1718,6 +1726,8 @@ paths: | |||
$ref: "#/components/responses/Unauthorized" | |||
404: | |||
$ref: "#/components/responses/NotFound" | |||
409: |
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.
In Git you can git tag --force
to overwrite an existing tag - In lakectl this happened implicitly for all tag creations, but it won't anymore. Maybe add --force
to the lakcetl command? (could simply delete and recreate it to simulate the current behavior).
(This could be done in another PR)
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.
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.
I think there's a bug in error handling for lakectl tags create --force
..
cmd/lakectl/cmd/tag.go
Outdated
DieOnResponseError(res, err) | ||
|
||
resp, err := client.DeleteTagWithResponse(ctx, tagURI.Repository, tagURI.Ref) | ||
if err != nil && resp != nil && resp.JSON404 == 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.
Wouldn't you want to die if there's an error but the response is 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.
Right, done.
docs/assets/js/swagger.yml
Outdated
@@ -236,6 +242,10 @@ components: | |||
size_bytes: | |||
type: integer | |||
format: int64 | |||
mtime: |
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.
you're going to publish an API that hasn't been released yet (well, same for yours)...
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.
Reverted.
c66eb86
to
36254b6
Compare
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 great, thanks :)
closes #1898