guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: publish: Do not path the empty string to 'query-p


From: guix-commits
Subject: branch master updated: publish: Do not path the empty string to 'query-path-info'.
Date: Wed, 04 Nov 2020 10:04:11 -0500

This is an automated email from the git hooks/post-receive script.

civodul pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new 5e7cf66  publish: Do not path the empty string to 'query-path-info'.
5e7cf66 is described below

commit 5e7cf66fb35780f930ad0bc5fe21ac330df4411d
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Nov 4 15:57:00 2020 +0100

    publish: Do not path the empty string to 'query-path-info'.
    
    Fixes <https://bugs.gnu.org/44442>.
    Regression introduced in 2b2ab7796ac186d88060793b8873fc0e21462758.
    
    * guix/scripts/publish.scm (render-nar/cached): Do not call
    'bypass-cache?' when ITEM is the empty string.
    * tests/publish.scm ("with cache, cache bypass, unmapped hash part"):
    New test.
---
 guix/scripts/publish.scm |  3 ++-
 tests/publish.scm        | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index 9706b52..e8faf37 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -681,7 +681,8 @@ return it; otherwise, return 404.  When TTL is true, use it 
as the
                   (item (and hash
                              (guard (c ((store-error? c) #f))
                                (hash-part->path store hash)))))
-             (and item (bypass-cache? store item)))
+             (and item (not (string-null? item))
+                  (bypass-cache? store item)))
            ;; Render STORE-ITEM live.  We reach this because STORE-ITEM is
            ;; being baked but clients are already asking for it.  Thus, we're
            ;; duplicating work, but doing so allows us to reduce delays.
diff --git a/tests/publish.scm b/tests/publish.scm
index 84aa6e5..e46e625 100644
--- a/tests/publish.scm
+++ b/tests/publish.scm
@@ -622,6 +622,41 @@ References: ~%"
                           (stat:size (stat item)))
                        (response-code response))))))))))
 
+(test-equal "with cache, cache bypass, unmapped hash part"
+  200
+
+  ;; This test reproduces the bug described in <https://bugs.gnu.org/44442>:
+  ;; the daemon connection would be closed as a side effect of a nar request
+  ;; for a non-existing file name.
+  (call-with-temporary-directory
+   (lambda (cache)
+     (let ((thread (with-separate-output-ports
+                    (call-with-new-thread
+                     (lambda ()
+                       (guix-publish "--port=6787" "-C" "gzip"
+                                     (string-append "--cache=" cache)))))))
+       (wait-until-ready 6787)
+
+       (let* ((base     "http://localhost:6787/";)
+              (item     (add-text-to-store %store "random" (random-text)))
+              (part     (store-path-hash-part item))
+              (narinfo  (string-append base part ".narinfo"))
+              (nar      (string-append base "nar/gzip/" (basename item)))
+              (cached   (string-append cache "/gzip/" (basename item)
+                                       ".narinfo")))
+         ;; The first response used to be 500 and to terminate the daemon
+         ;; connection as a side effect.
+         (and (= (response-code
+                  (http-get (string-append base "nar/gzip/"
+                                           (make-string 32 #\e)
+                                           "-does-not-exist")))
+                 404)
+              (= 200 (response-code (http-get nar)))
+              (= 200 (response-code (http-get narinfo)))
+              (begin
+                (wait-for-file cached)
+                (response-code (http-get nar)))))))))
+
 (test-equal "/log/NAME"
   `(200 #t application/x-bzip2)
   (let ((drv (run-with-store %store



reply via email to

[Prev in Thread] Current Thread [Next in Thread]