diff --git a/guix-data-service/web/revision/controller.scm b/guix-data-service/web/revision/controller.scm index 0739b78..a64d314 100644 --- a/guix-data-service/web/revision/controller.scm +++ b/guix-data-service/web/revision/controller.scm @@ -993,28 +993,34 @@ '(application/json text/html) mime-types) ((application/json) - (render-json - `((name . ,name) - (version . ,version) - ,@(match metadata - (((synopsis synopsis-locale description description-locale home-page file line column-number - licenses)) - `((synopsis . ,(texinfo->variants-alist synopsis synopsis-locale)) - (description . ,(texinfo->variants-alist description description-locale)) - (location - . ((file . ,file) - (line . ,line) - (column . ,column-number))) - (home-page . ,home-page)))) - (derivations . ,(list->vector - (map (match-lambda - ((system target file-name status outputs) - `((system . ,system) - (target . ,target) - (derivation . ,file-name) - (outputs . ,(list->vector outputs))))) - derivations)))) - #:extra-headers http-headers-for-unchanging-content)) + (if (null? metadata) + (render-json + `((name . ,name) + (version . ,version) + (error . "package not found")) + #:code 404) + (render-json + `((name . ,name) + (version . ,version) + ,@(match metadata + (((synopsis synopsis-locale description description-locale home-page file line column-number + licenses)) + `((synopsis . ,(texinfo->variants-alist synopsis synopsis-locale)) + (description . ,(texinfo->variants-alist description description-locale)) + (location + . ((file . ,file) + (line . ,line) + (column . ,column-number))) + (home-page . ,home-page)))) + (derivations . ,(list->vector + (map (match-lambda + ((system target file-name status outputs) + `((system . ,system) + (target . ,target) + (derivation . ,file-name) + (outputs . ,(list->vector outputs))))) + derivations)))) + #:extra-headers http-headers-for-unchanging-content))) (else (render-html #:sxml (view-revision-package-and-version commit-hash @@ -1030,6 +1036,9 @@ #:header-link header-link #:version-history-link version-history-link) + #:code (if (null? metadata) + 404 + 200) #:extra-headers http-headers-for-unchanging-content))))) (define* (render-revision-package-derivations mime-types diff --git a/guix-data-service/web/revision/html.scm b/guix-data-service/web/revision/html.scm index 04133ad..45d1fc5 100644 --- a/guix-data-service/web/revision/html.scm +++ b/guix-data-service/web/revision/html.scm @@ -243,6 +243,8 @@ (div (@ (class "col-sm-12")) ,(match package-metadata + (() + "Package not found at this version") (((synopsis synopsis-locale description description-locale home-page file line column-number licenses)) `(dl