aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2020-08-02 15:50:59 +0200
committerMathieu Othacehe <othacehe@gnu.org>2020-08-02 15:50:59 +0200
commit769682924c8f8d26d426f8111a538580ec5b2b20 (patch)
treec2489dbed47a4be15314de1c48718536e0848673 /src
parent153b49c952eb0238329355590fc7d965ceb504e8 (diff)
downloadcuirass-769682924c8f8d26d426f8111a538580ec5b2b20.tar
cuirass-769682924c8f8d26d426f8111a538580ec5b2b20.tar.gz
http: Handle wrong build number.
The request "/build/1234)" causes a select query on the whole Builds table, because failed "string->number" conversion is not handled. * src/cuirass/http.scm (url-handler): Handle erroneous id -> number conversion on "/build/id" route.
Diffstat (limited to 'src')
-rw-r--r--src/cuirass/http.scm9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index e7f0da7..fdcdc06 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -354,10 +354,11 @@ Hydra format."
(respond-json (object->json-string
(list->vector (db-get-specifications)))))
(('GET "build" id)
- (let ((hydra-build (handle-build-request
- (if (string-suffix? ".drv" id)
- (string-append (%store-prefix) "/" id)
- (string->number id)))))
+ (let* ((build (if (string-suffix? ".drv" id)
+ (string-append (%store-prefix) "/" id)
+ (string->number id)))
+ (hydra-build (and build
+ (handle-build-request build))))
(if hydra-build
(respond-json (object->json-string hydra-build))
(respond-build-not-found id))))