-
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
Branch protection status code should be 403 #5273
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! Just a couple of minor things to change:
- Create a swagger error type for
Forbidden
errors (currently the errors are returned with a description ofInternal Server Error
) - Handle the other error that may rise from committing to a protected branch
- Verify that merging could fail due to branch protection? if so, in which case? (i.e. if this is really the case, this requires documentation)
api/swagger.yml
Outdated
@@ -2605,6 +2605,8 @@ paths: | |||
$ref: "#/components/responses/ValidationError" | |||
401: | |||
$ref: "#/components/responses/Unauthorized" | |||
403: | |||
$ref: "#/components/responses/ServerError" |
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 should probably be a new error type as this message is still described as an internal server error
@@ -2762,6 +2766,8 @@ paths: | |||
$ref: "#/components/responses/ValidationError" | |||
401: | |||
$ref: "#/components/responses/Unauthorized" | |||
403: |
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.
Can a merge operation fail due to branch protection?
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 are right - I thought we added this feature. Was asked once, on how we can support read-only branch while branch protection commit doesn't stop merge's commit.
I'll keep the status code on the interface unless you think it will be confusion?
pkg/api/controller.go
Outdated
@@ -1849,6 +1849,9 @@ func (c *Controller) handleAPIErrorCallback(ctx context.Context, w http.Response | |||
errors.Is(err, kv.ErrNotFound): | |||
cb(w, r, http.StatusNotFound, err) | |||
|
|||
case errors.Is(err, graveler.ErrWriteToProtectedBranch): |
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.
There's also a specific error returned when trying to commit to a protected branch (see ErrCommitToProtectedBranch), which this doesn't cover
@@ -213,6 +213,7 @@ public okhttp3.Call createBranchAsync(String repository, BranchCreation branchCr | |||
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> | |||
<tr><td> 204 </td><td> branch deleted successfully </td><td> - </td></tr> | |||
<tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> | |||
<tr><td> 403 </td><td> Internal Server Error </td><td> - </td></tr> |
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.
Example of why this is confusing :)
Thanks for the input - did better work in the next commit:
|
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.
Great! thank you!
Close #5272