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

Return 404 NotFound if requested attachment does not exist (#20886) #20941

Merged
merged 2 commits into from
Aug 25, 2022
Merged
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
20 changes: 20 additions & 0 deletions routers/api/v1/repo/release_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func GetReleaseAttachment(ctx *context.APIContext) {
attachID := ctx.ParamsInt64(":asset")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
ctx.NotFound()
return
}
ctx.Error(http.StatusInternalServerError, "GetAttachmentByID", err)
return
}
Expand Down Expand Up @@ -100,6 +104,10 @@ func ListReleaseAttachments(ctx *context.APIContext) {
releaseID := ctx.ParamsInt64(":id")
release, err := models.GetReleaseByID(ctx, releaseID)
if err != nil {
if models.IsErrReleaseNotExist(err) {
ctx.NotFound()
return
}
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err)
return
}
Expand Down Expand Up @@ -166,6 +174,10 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
releaseID := ctx.ParamsInt64(":id")
release, err := models.GetReleaseByID(ctx, releaseID)
if err != nil {
if models.IsErrReleaseNotExist(err) {
ctx.NotFound()
return
}
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err)
return
}
Expand Down Expand Up @@ -244,6 +256,10 @@ func EditReleaseAttachment(ctx *context.APIContext) {
attachID := ctx.ParamsInt64(":asset")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
ctx.NotFound()
return
}
ctx.Error(http.StatusInternalServerError, "GetAttachmentByID", err)
return
}
Expand Down Expand Up @@ -302,6 +318,10 @@ func DeleteReleaseAttachment(ctx *context.APIContext) {
attachID := ctx.ParamsInt64(":asset")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
ctx.NotFound()
return
}
ctx.Error(http.StatusInternalServerError, "GetAttachmentByID", err)
return
}
Expand Down