Subject: [bug#70227] [PATCH 1/2] guix: import: composer: Handle parsing failures.

From: Nicolas Graves <[email-masked]>
Date: Sat, 6 Apr 2024 04:08:50 +0200

* guix/import/composer (latest-release): Handle parsing
failures. Rename package to composer-package for clarity.

Change-Id: I57f6fba7b05122b031177681e76cf0b5c9547736
---
 guix/import/composer.scm | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/guix/import/composer.scm b/guix/import/composer.scm
index 1ad608964b..75419ca63e 100644
--- a/guix/import/composer.scm
+++ b/guix/import/composer.scm
@@ -243,16 +243,19 @@ (define (php-package? package)
    (eq? (package-build-system package) composer-build-system)
    (string-prefix? "php-" (package-name package))))
 
-(define (latest-release package)
+(define* (latest-release package #:key (version #f))
   "Return an <upstream-source> for the latest release of PACKAGE."
   (let* ((php-name (guix-package->composer-name package))
-         (package (composer-fetch php-name))
-         (version (composer-package-version package))
-         (url (composer-source-url (composer-package-source package))))
-    (upstream-source
-     (package (package-name package))
-     (version version)
-     (urls (list url)))))
+         (composer-package (composer-fetch php-name #:version version)))
+    (if composer-package
+        (upstream-source
+         (package (composer-package-name composer-package))
+         (version (composer-package-version composer-package))
+         (urls (list (composer-source-url
+                      (composer-package-source composer-package)))))
+        (begin
+          (warning (G_ "failed to parse ~a~%") php-name)
+          #f))))
 
 (define %composer-updater
   (upstream-updater
-- 
2.41.0