Skip to content

Commit

Permalink
Fix: return bad request on reset branch with unknown type (#7210)
Browse files Browse the repository at this point in the history
* fix reset branch unknown type status code

* Return bad request status code on invalid type

* update error message
  • Loading branch information
nopcoder authored Dec 30, 2023
1 parent f450801 commit 9896225
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,8 @@ paths:
responses:
204:
description: reset successful
400:
$ref: "#/components/responses/BadRequest"
401:
$ref: "#/components/responses/Unauthorized"
403:
Expand Down
6 changes: 6 additions & 0 deletions clients/java-legacy/api/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/java-legacy/docs/BranchesApi.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions clients/java/api/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/java/docs/BranchesApi.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/python-legacy/docs/BranchesApi.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/python/docs/BranchesApi.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/assets/js/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,8 @@ paths:
responses:
204:
description: reset successful
400:
$ref: "#/components/responses/BadRequest"
401:
$ref: "#/components/responses/Unauthorized"
403:
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,8 @@ func (c *Controller) ResetBranch(w http.ResponseWriter, r *http.Request, body ap
case entryTypeObject:
err = c.Catalog.ResetEntry(ctx, repository, branch, swag.StringValue(body.Path), graveler.WithForce(swag.BoolValue(body.Force)))
default:
writeError(w, r, http.StatusNotFound, "reset type not found")
writeError(w, r, http.StatusBadRequest, "unknown reset type")
return
}
if c.handleAPIError(ctx, w, r, err) {
return
Expand Down

0 comments on commit 9896225

Please sign in to comment.