From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WHISBQJi92BB6QAAgWs5BA (envelope-from ) for ; Wed, 21 Jul 2021 01:53:38 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id gJCZAAJi92CpWgAA1q6Kng (envelope-from ) for ; Tue, 20 Jul 2021 23:53:38 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8119B1B29E for ; Wed, 21 Jul 2021 01:53:37 +0200 (CEST) Received: from localhost ([::1]:47882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5zYO-0007Ud-Em for larch@yhetil.org; Tue, 20 Jul 2021 19:53:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5zNC-0008Df-RG for guix-patches@gnu.org; Tue, 20 Jul 2021 19:42:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m5zNC-0006a9-Ia for guix-patches@gnu.org; Tue, 20 Jul 2021 19:42:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m5zNC-0006cn-Dj for guix-patches@gnu.org; Tue, 20 Jul 2021 19:42:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49671] [PATCH] guix: records: Improve error reporting. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 20 Jul 2021 23:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49671 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49671@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162682447525407 (code B ref -1); Tue, 20 Jul 2021 23:42:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jul 2021 23:41:15 +0000 Received: from localhost ([127.0.0.1]:35682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5zMQ-0006bi-JL for submit@debbugs.gnu.org; Tue, 20 Jul 2021 19:41:14 -0400 Received: from lists.gnu.org ([209.51.188.17]:52842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5zMO-0006bb-OL for submit@debbugs.gnu.org; Tue, 20 Jul 2021 19:41:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5zMN-0006g2-At for guix-patches@gnu.org; Tue, 20 Jul 2021 19:41:11 -0400 Received: from lepiller.eu ([2a00:5884:8208::1]:41982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5zMJ-0005sI-Dg for guix-patches@gnu.org; Tue, 20 Jul 2021 19:41:10 -0400 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 3e99d9b3 for ; Tue, 20 Jul 2021 23:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:subject:message-id:mime-version:content-type; s=dkim; bh=Jzv L5p/FEwCJ8aKOL34W4e/+7g+irLG2mi7B79llZOo=; b=R4CRQysHkDD5S/eZfR2 rYy2QmQfl8P5+3YLV+ZDkniK4wcw7vEEt0pt3JdK2m8or/KVvPFueX+R8E1tznfe Y9e66xsIS3Mr0th51irTcVEuYWB9fllC/810K36rGPquuATaVnp8+ko8VboStIgK CQtHdawfzaCwJass2+dNVEc/vRHGqHd8lPJzc3DGTZSGxvJ1KGCoMg6fKGtM6d0e Jjv+UkHZLxOQHllGmOdyTPQborpi/F6jn61Uzwrb+ZlrG4WD4IEnHoWr8qveyAuU UTYrKQAf/s7cWBc1M5UhM3IQieoxnzAN+VyUPMrk/cJFJsOMj6MJjuisF7Q1WDiD fHQ== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id acbfdb09 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Tue, 20 Jul 2021 23:41:00 +0000 (UTC) Date: Wed, 21 Jul 2021 01:40:47 +0200 From: Julien Lepiller Message-ID: <20210721014047.3878a0c7@tachikoma.lepiller.eu> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/e6eTRR3_p7yxMS_Ql97axbF" Received-SPF: pass client-ip=2a00:5884:8208::1; envelope-from=julien@lepiller.eu; helo=lepiller.eu X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1626825217; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=Y7OKXFPSS3gMdNXc9Te4n3PsscBL46LX4lPWIbjGS5U=; b=EHpV19pOJACneNZvXPOVZKblxZ4pTO9is02t6jBaxa0b1hhd7JL9uP5SFaF1aADePKAz9F TZBj8gG+ejVqF4nfmJ9wG9tPQgB7r2PLErNkDxKpjLaRw5HBTPZ5QSoOyvdvabBW+OK34+ ZUzYROn5MBaqHGFlANrYeco4CDXfMRWD96Kxxk/BJaI4rk0oMSV/A18GY+RfwtgkaRSPvW Vi5TF/ToHg01uBpYyz3PbkqZ3/ylmGsT4fkE2ehP4i052wGYLS6QI/om2lJ+MHAsCzmF4Y 18+mH6/IqnpLHIAZ7XOfdIJsmqYmOPOJwaAjecQCbMRt8mTqXSmzMGqvptv1WQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1626825217; a=rsa-sha256; cv=none; b=jYZn0XUTzfRovvG2nDxrYETmQkXI+RLZdtN6PoqJX01o6zple3RhfVNUQfluGcNIVGXi8T c4wqoxONxQKjhT3aW7X+Eue1cVLd8FzXvkNBjF330n8Z7kH3DvGpOwEiInicyuexmqm8Ib yeFOhZrV22TFSSYQhjF4Hwy6+vpe8sAV5VX+WEhUbJtiX8JjggLOIsiq6zxvbyGVaSbTnZ yHBrW5JB96Hy1+NC/Mof+4hxYcisOOcXlGSOAw9n1FBhOPLLRxqvuGCLso7KHUSoVo6vdu IUhsc5yTO6I+1ToWP+8bx1RdZ5skBVyvLvTcsJaA7qECz2R6CBoKZmVnSfTrNg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=R4CRQysH; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lepiller.eu header.s=dkim header.b=R4CRQysH; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 8119B1B29E X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: nRJiJ7rVW/Rs --MP_/e6eTRR3_p7yxMS_Ql97axbF Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Guix! This patch improves error reporting a bit when making mistakes in guix records. This is motivated by a user getting "invalid field specifier" for their whole services field in their os record. With this patches, they would have seen: multiple values in field specifier. Got 2 values associated with key services. Values are: (append (list (service ...) ...)) (modify-services %desktop-services ...) Which would have hinted them at fixing the parenthesis. Or at least, it would have saved us some time trying to count them :) Here are the cases that are handled and the associated message: (operating-system services) guix system: error: services: invalid field specifier. The format of a field is `(services value)' (operating-system (services)) test.scm:2:2: error: (services): Value missing in field specifier. The format of a field is `(services value)'. (operating-system (services 1 2 3)) test.scm:2:2: error: (services 1 2 3): multiple values in field specifier. Got 3 values associated with key services. Values are: 1 2 3 (operating-system ()) guix system: error: (): invalid field specifier. The format of a field is `(field value)' (operating-system ((services %desktop-services))) test.scm:2:2: error: ((services %desktop-services)): invalid field specifier. (services %desktop-services) is not a valid field name. Of course, we can improve these error messages, and internationalize them. WDYT? --MP_/e6eTRR3_p7yxMS_Ql97axbF Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=0001-guix-records-Improve-error-reporting.patch =46rom 4cde5555682ca6a3c78cb274cc308087e51ea0e9 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Wed, 21 Jul 2021 01:30:04 +0200 Subject: [PATCH] guix: records: Improve error reporting. * guix/records.scm (report-invalid-field-specifier): Handle various invalidity causes separately. --- guix/records.scm | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index 3d54a51956..3c3dd478a5 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 = Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2018 Mark H Weaver +;;; Copyright =C2=A9 2021 Julien Lepiller ;;; ;;; This file is part of GNU Guix. ;;; @@ -83,10 +84,40 @@ error-reporting purposes." ;; WEIRD may be an identifier, thus lacking source location info,= and ;; BINDINGS is a list, also lacking source location info. Hopefu= lly ;; PARENT-FORM provides source location info. - (apply syntax-violation name "invalid field specifier" - (if parent-form + (syntax-case #'weird () + (() ;the empty list + (apply syntax-violation name + "invalid field specifier. The format of a field is `(f= ield value)'" (list parent-form #'weird) - (list #'weird))))))) + (list #'weird))) + (((field ...) _ ...) ;a list whose first element is = a list + (apply syntax-violation name + (format #f "invalid field specifier. ~a is not a valid = field name." + (map syntax->datum #'(field ...))) + (list parent-form #'weird) + (list #'weird))) + ((field) ;a list with one element + (apply syntax-violation name + (format #f "Value missing in field specifier. The forma= t of \ +a field is `(~a value)'." + (syntax->datum #'field)) + (list parent-form #'weird) + (list #'weird))) + ((field value ...) ;any other list + (apply syntax-violation name + (format #f "multiple values in field specifier. Got ~a = values \ +associated with key ~a. Values are:~%~{~a~%~}" + (length #'(value ...)) (syntax->datum #'field) + (map syntax->datum #'(value ...))) + (list parent-form #'weird) + (list #'weird))) + (field ;not a list + (apply syntax-violation name + (format #f "invalid field specifier. The format of a f= ield \ +is `(~a value)'" + (syntax->datum #'field)) + (list parent-form #'weird) + (list #'weird)))))))) =20 (define (report-duplicate-field-specifier name ctor) "Report the first duplicate identifier among the bindings in CTOR." --=20 2.32.0 --MP_/e6eTRR3_p7yxMS_Ql97axbF--