From patchwork Sat Mar 16 10:30:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christina O'Donnell X-Patchwork-Id: 61869 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9A04527BBEC; Sat, 16 Mar 2024 10:31:52 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id CF8F727BBEA for ; Sat, 16 Mar 2024 10:31:51 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rlRKB-0001uC-N4; Sat, 16 Mar 2024 06:31:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlRK4-0001tf-AH for guix-patches@gnu.org; Sat, 16 Mar 2024 06:31:28 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlRK2-0001Qg-Hv for guix-patches@gnu.org; Sat, 16 Mar 2024 06:31:27 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rlRKd-00061j-9t; Sat, 16 Mar 2024 06:32:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69827] [PATCH 3/3] import/go: Add diagnostics. Resent-From: Christina O'Donnell Original-Sender: "Debbugs-submit" Resent-CC: cox.katherine.e+guix@gmail.com, sharlatanus@gmail.com, guix-patches@gnu.org Resent-Date: Sat, 16 Mar 2024 10:32:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69827 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69827@debbugs.gnu.org Cc: Christina O'Donnell , Katherine Cox-Buday , Sharlatan Hellseher X-Debbugs-Original-Xcc: Katherine Cox-Buday , Sharlatan Hellseher Received: via spool by 69827-submit@debbugs.gnu.org id=B69827.171058508323071 (code B ref 69827); Sat, 16 Mar 2024 10:32:03 +0000 Received: (at 69827) by debbugs.gnu.org; 16 Mar 2024 10:31:23 +0000 Received: from localhost ([127.0.0.1]:54889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlRJy-000602-Jf for submit@debbugs.gnu.org; Sat, 16 Mar 2024 06:31:23 -0400 Received: from vmi993448.contaboserver.net ([194.163.141.236]:40890 helo=mutix.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlRJw-0005zq-N9 for 69827@debbugs.gnu.org; Sat, 16 Mar 2024 06:31:21 -0400 Received: from [86.132.246.87] (host81-147-82-218.range81-147.btcentralplus.com [81.147.82.218]) (Authenticated sender: cdo) by mutix.org (Postfix) with ESMTPSA id 25356A63582; Sat, 16 Mar 2024 11:30:43 +0100 (CET) From: Christina O'Donnell Date: Sat, 16 Mar 2024 10:30:39 +0000 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches guix/import/go.scm (go-module-available-versions): Add warning when fetching a list of versions from the proxy fails and raise exception when no version can be found at all. (module-path->repository-root): Warn when all attempts to find the repository root have failed. (fetch-module-meta-data): Raise exception when no meta element could be found. (go-module->guix-package): Catch general exceptions and warn that the package could not be imported. Change-Id: I6dcdccc71f54bfec7110f6bfc5aeb8855502d1e3 --- guix/import/go.scm | 56 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index 8276797d9a..5dd5b3d221 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -140,10 +140,15 @@ (define* (go-module-available-versions goproxy name) (versions (remove string-null? (string-split body #\newline)))) (if (null? versions) (begin + (warning (G_ "Empty list of versions on proxy ~a for package '~a'. Using latest.~%") + goproxy name) ;; If we haven't recieved any versions, look in the version-info json ;; object and return a one-element list if found. (or (and=> (assoc-ref (go-module-version-info goproxy name) "Version") - list)))) + list) + (raise (make-compound-condition + (formatted-message (G_ "No versions available for '~a' on proxy ~a.") + name goproxy)))))) versions)) (define (go-package-licenses name) @@ -467,7 +472,10 @@ (define (module-path->repository-root module-path version-info) (+ 1 (string-length subdir))) #f))))) (vcs-qualified-module-path->root-repo-url module-path) - module-path)) + (begin + (warning (G_ "Unable to determine repository root of '~a'. Guessing '~a'.~%") + module-path module-path) + module-path))) (define* (go-module->guix-package-name module-path #:optional version) "Converts a module's path to the canonical Guix format for Go packages. @@ -512,14 +520,19 @@ (define (fetch-module-meta-data module-path) (select (sxpath `(// (meta (@ (equal? (name "go-import")))) // content)))) (match (select (html->sxml meta-data #:strict? #t)) - (() #f) ;nothing selected + (() (raise (make-compound-condition + (formatted-message (G_ "no element in result when accessing module path '~a' using go-get") + module-path)))) ((('content content-text) ..1) (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))))))) + (go-import->module-meta (first content-text)) + (raise (make-compound-condition + (formatted-message (G_ "unable to parse when accessing module path '~a' using go-get") + module-path)))))))) (define (module-meta-data-repo-url meta-data goproxy) "Return the URL where the fetcher which will be used can download the @@ -716,16 +729,35 @@ (define go-module->guix-package* ;; consistently. (setvbuf (current-error-port) 'none) (let ((package-name (match args ((name _ ...) name)))) - (guard (c ((http-get-error? c) - (warning (G_ "Failed to import package ~s. + (begin + (info (G_ "Importing package ~s...~%") package-name) + (guard (c ((http-get-error? c) + (warning (G_ "Failed to import package ~s. reason: ~s could not be fetched: HTTP error ~a (~s). This package and its dependencies won't be imported.~%") - package-name - (uri->string (http-get-error-uri c)) - (http-get-error-code c) - (http-get-error-reason c)) - (values #f '()))) - (apply go-module->guix-package args))))) + package-name + (uri->string (http-get-error-uri c)) + (http-get-error-code c) + (http-get-error-reason c)) + + (values #f '())) + ((formatted-message? c) + (warning (G_ "Failed to import package ~s. +reason: ~a +This package and its dependencies won't be imported.~%") + package-name + (apply format #f + (formatted-message-string c) + (formatted-message-arguments c))) + (values #f '())) + ((git-error? c) + (warning (G_ "Failed to import package ~s. +reason: ~a +This package and its dependencies won't be imported.~%") + package-name + (git-error-message c)) + (values #f '()))) + (apply go-module->guix-package args)))))) (define* (go-module-recursive-import package-name #:key (goproxy "https://proxy.golang.org")