GNU bug report logs - #71928
[PATCH] gnu: Throw error when extending services that do not use extensions.

Previous Next

Package: guix-patches;

Reported by: Richard Sent <richard <at> freakingpenguin.com>

Date: Wed, 3 Jul 2024 22:14:02 UTC

Severity: normal

Tags: moreinfo, patch

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: Richard Sent <richard <at> freakingpenguin.com>
Cc: 71928 <at> debbugs.gnu.org
Subject: [bug#71928] [PATCH v2] gnu: Throw error when extending services that do not use extensions.
Date: Mon, 30 Sep 2024 22:43:36 +0200
Hello,

Richard Sent <richard <at> freakingpenguin.com> skribis:

> * gnu/services.scm (fold-services): Add error handling when using service
> extensions.
>
> Fixes: https://issues.guix.gnu.org/71887
> Change-Id: Ic8d631674bfddde495c93952d9e6cd5649bb287d

[...]

> @@ -1223,12 +1224,22 @@ (define* (fold-services services
>                       (params     -> (service-value sink))
>                       (service
>                        ->
> -                      ;; Distinguish COMPOSE and EXTEND because PARAMS typically
> -                      ;; has a different type than the elements of EXTENSIONS.
> -                      (if extend
> -                          (service (service-kind sink)
> -                                   (extend params (compose extensions)))
> -                          sink)))
> +                      (begin
> +                        (unless (or (null? extensions)
> +                                    ;; A value of #t is a convention for "make
> +                                    ;; sure the service is present."
> +                                    (every (cut eq? #t <>) extensions)
> +                                    (and extend compose))
> +                          (error (format #f "Extensions are not supported in \
> +~a yet the following service types extend it:~{~%   ~a~}"
> +                                         (service-kind sink)
> +                                         (map service-kind dependents))))
> +                        ;; Distinguish COMPOSE and EXTEND because PARAMS typically
> +                        ;; has a different type than the elements of EXTENSIONS.
> +                        (if extend
> +                            (service (service-kind sink)
> +                                     (extend params (compose extensions)))
> +                            sink))))

I understand the current situation where extensions to a non-extensible
service are silently swallowed is suboptimal, but I wonder about the
implications of the semantic change here.

Currently the “#t means ensure the service is present” convention is not
enforced; is it even widely followed in the Guix repo?  But then, what
about repos out there that provide services?

It would seem to me that this is something that cannot be changed
overnight without running the risk to break people’s code.  So perhaps
the first step (and maybe last step?) would be to print a warning.

WDYT?

Thanks,
Ludo’.




This bug report was last modified 153 days ago.

Previous Next


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