aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2023-11-05 19:58:31 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2023-11-05 19:58:31 +0200
commit20542100b76e2caed92b5b8dd266ac8912d0066c (patch)
tree261e68cf0434d3ab2ff5069477f3e9e5687f34e2
parentapp/packages: add codeberg remote-id (diff)
downloadsoko-20542100b76e2caed92b5b8dd266ac8912d0066c.tar.gz
soko-20542100b76e2caed92b5b8dd266ac8912d0066c.tar.bz2
soko-20542100b76e2caed92b5b8dd266ac8912d0066c.zip
app/packages/json: fix panic for unknown packages
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--pkg/app/handler/packages/json.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/app/handler/packages/json.go b/pkg/app/handler/packages/json.go
index b4b6e81..8621736 100644
--- a/pkg/app/handler/packages/json.go
+++ b/pkg/app/handler/packages/json.go
@@ -25,7 +25,10 @@ func buildJson(w http.ResponseWriter, r *http.Request) {
}).
Select()
- if err != nil && err != pg.ErrNoRows {
+ if err == pg.ErrNoRows {
+ http.NotFound(w, r)
+ return
+ } else if err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError),
http.StatusInternalServerError)
return
@@ -33,6 +36,11 @@ func buildJson(w http.ResponseWriter, r *http.Request) {
sortVersionsDesc(gpackage.Versions)
+ if len(gpackage.Versions) == 0 || len(gpackage.Commits) == 0 {
+ http.NotFound(w, r)
+ return
+ }
+
versions := getJSONVersions(gpackage)
maintainers := getJSONMaintainers(gpackage)
useflags := getJSONUseflag(gpackage)