GNU bug report logs - #50289
[PATCH] import: go: Fix import when import path redirects.

Previous Next

Package: guix-patches;

Reported by: Sarah Morgensen <iskarian <at> mgsn.dev>

Date: Tue, 31 Aug 2021 02:06:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50289 in the body.
You can then email your comments to 50289 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to attila <at> lendvai.name, guix-patches <at> gnu.org:
bug#50289; Package guix-patches. (Tue, 31 Aug 2021 02:06:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
New bug report received and forwarded. Copy sent to attila <at> lendvai.name, guix-patches <at> gnu.org. (Tue, 31 Aug 2021 02:06:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: guix-patches <at> gnu.org
Subject: [PATCH] import: go: Fix import when import path redirects.
Date: Mon, 30 Aug 2021 19:05:19 -0700
* guix/import/go.scm (fetch-module-meta-data): If no meta entries
have a matching import prefix, return the first entry instead of #f.
---
X-Debbugs-CC: Attila Lendvai <attila <at> lendvai.name>

Hello Guix,

As reported by Attila on IRC, the Go importer currently chokes when the
import path URL redirects, for example with "github.com/prometheus/tsdb".

This is due to my modification to 'fetch-module-meta-data' to handle multiple
package's meta tags on one page [0].  It selects the meta based on whether its
import prefix matches the URL we requested.  This breaks when the URL
redirects but the import path is not changed (I did not realize that this
was valid... go figure).  This patch fixes that by falling back to the first
meta if none match.

[0] https://issues.guix.gnu.org/49591

--
Sarah

 guix/import/go.scm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/guix/import/go.scm b/guix/import/go.scm
index 617a0d0e23..57a135b9a9 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -483,9 +483,12 @@ (define (fetch-module-meta-data module-path)
     (match (select (html->sxml meta-data #:strict? #t))
       (() #f)                           ;nothing selected
       ((('content content-text) ..1)
-       (find (lambda (meta)
-               (string-prefix? (module-meta-import-prefix meta) module-path))
-             (map go-import->module-meta content-text))))))
+       (or
+        (find (lambda (meta)
+                (string-prefix? (module-meta-import-prefix meta) module-path))
+              (map go-import->module-meta content-text))
+        ;; Fallback to the first meta if no import prefixes match.
+        (go-import->module-meta (first content-text)))))))
 
 (define (module-meta-data-repo-url meta-data goproxy)
   "Return the URL where the fetcher which will be used can download the

base-commit: 994d8ce394e88b55985241b7b14f6a8459bcf9e8
-- 
2.31.1





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Tue, 07 Sep 2021 13:56:02 GMT) Full text and rfc822 format available.

Notification sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
bug acknowledged by developer. (Tue, 07 Sep 2021 13:56:02 GMT) Full text and rfc822 format available.

Message #10 received at 50289-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: Attila Lendvai <attila <at> lendvai.name>, 50289-done <at> debbugs.gnu.org
Subject: Re: bug#50289: [PATCH] import: go: Fix import when import path
 redirects.
Date: Tue, 07 Sep 2021 15:55:16 +0200
Hi,

Sarah Morgensen <iskarian <at> mgsn.dev> skribis:

> * guix/import/go.scm (fetch-module-meta-data): If no meta entries
> have a matching import prefix, return the first entry instead of #f.
> ---
> X-Debbugs-CC: Attila Lendvai <attila <at> lendvai.name>
>
> Hello Guix,
>
> As reported by Attila on IRC, the Go importer currently chokes when the
> import path URL redirects, for example with "github.com/prometheus/tsdb".
>
> This is due to my modification to 'fetch-module-meta-data' to handle multiple
> package's meta tags on one page [0].  It selects the meta based on whether its
> import prefix matches the URL we requested.  This breaks when the URL
> redirects but the import path is not changed (I did not realize that this
> was valid... go figure).  This patch fixes that by falling back to the first
> meta if none match.
>
> [0] https://issues.guix.gnu.org/49591

Applied, thank you!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 06 Oct 2021 11:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 174 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.