From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id D5IAE/ORtGJ0cAAAbAwnHQ (envelope-from ) for ; Thu, 23 Jun 2022 18:16:51 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 8LLDEfORtGI0SgEA9RJhRA (envelope-from ) for ; Thu, 23 Jun 2022 18:16:51 +0200 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 F210618849 for ; Thu, 23 Jun 2022 18:16:50 +0200 (CEST) Received: from localhost ([::1]:37042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4PVf-0004Ew-1t for larch@yhetil.org; Thu, 23 Jun 2022 12:16:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4PLI-0007vq-27 for guix-patches@gnu.org; Thu, 23 Jun 2022 12:06:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45745) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4PLG-0006uE-N6 for guix-patches@gnu.org; Thu, 23 Jun 2022 12:06:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o4PLG-0005MN-Bp for guix-patches@gnu.org; Thu, 23 Jun 2022 12:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56075] [PATCH 1/2] services: configuration: Report the location of field type errors. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 23 Jun 2022 16:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56075 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 56075@debbugs.gnu.org Received: via spool by 56075-submit@debbugs.gnu.org id=B56075.165600032820539 (code B ref 56075); Thu, 23 Jun 2022 16:06:02 +0000 Received: (at 56075) by debbugs.gnu.org; 23 Jun 2022 16:05:28 +0000 Received: from localhost ([127.0.0.1]:39642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4PKh-0005LC-T2 for submit@debbugs.gnu.org; Thu, 23 Jun 2022 12:05:28 -0400 Received: from mail-qk1-f169.google.com ([209.85.222.169]:40713) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4PKe-0005Kt-RO for 56075@debbugs.gnu.org; Thu, 23 Jun 2022 12:05:27 -0400 Received: by mail-qk1-f169.google.com with SMTP id p21so3289139qki.7 for <56075@debbugs.gnu.org>; Thu, 23 Jun 2022 09:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=j+qHXjpljw2+Iitx9Om3Glg/6jXKw2zb7ntKs1UCClQ=; b=U5WZPmCt1QhQkb/uzDDVLeA6F/sG/idbRQqvVqeg6KVzvQdPPx3uvWW6pgFwanmsGs LgSQQlkjZMWjI+OdV9OVxeHC7PCC4jOBqIPWsbapkFXjWsAam5SrteayvRWpqslqN0H9 03f2ohNU1hfYLzZPyvQMia24Z5JTbL3mMRjgCW5KUdkaCw1sTIonWgx2sPVfWskHV/CI AJiCLL01MYxuZ6RCjtjh3YltH52IVoEEKhzgoo94tFLJHmocVEA+wOfBO7JZGEnLHg6u /YROKkGgPFAYXoWOvYTcwoe/hv6fbEppMxStgEaWIXq1VoM+0xbHnlD/5kE/JpbyMLaq HQHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=j+qHXjpljw2+Iitx9Om3Glg/6jXKw2zb7ntKs1UCClQ=; b=cEzIRfJIFz6/Y7UiU/fyvQOohQ7m9gtw8r8OZyE9QEUkjIDz9eu2DCLulz/4p+hSrW qGeM0tSwh3fMpqZYke+668mNtsoYerDBymN6kRPAJZMOk4Y9zwHbctxqTP1B9UUtsjK7 Ijr6MeGIqSjzDa8Cr9EL/3H7PMTULK2XiJd+an3n6fbHvlkepFKn14t4p2PLJzbrWmol KAR9zzA+6raVelSXrV6I1wfn0SIQdZt0eWzIc7O8WhrszBS5RLHAAZFaddFSn3fWKpUF AhC2PHWFNiV+WxThlpwqwNgb46XiRwvaCBmLlzQSDJDO0xWH0vSwiTPh2pegdiqYgY2l Ivfg== X-Gm-Message-State: AJIora9zGaPtA32Eq0sQZ3+QluehrEdnfonJCQHLDq/z0BkLRHymcmCt 4dz7eyygrmg8uqpve/CbLROGYV2vzHgw1BmV X-Google-Smtp-Source: AGRyM1vvHyeLc8RBb/V6yOVsoFajhJ3hMjt3nTakxEfD4FZ5IvY4O97Qdgoj3upOlUj4HFKYm6TX7g== X-Received: by 2002:a37:a5d0:0:b0:6a6:7cbc:dc2a with SMTP id o199-20020a37a5d0000000b006a67cbcdc2amr6943012qke.496.1656000318421; Thu, 23 Jun 2022 09:05:18 -0700 (PDT) Received: from hurd (dsl-158-129.b2b2c.ca. [66.158.158.129]) by smtp.gmail.com with ESMTPSA id ey6-20020a05622a4c0600b0030a9dfb2898sm10375965qtb.85.2022.06.23.09.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 09:05:18 -0700 (PDT) From: Maxim Cournoyer References: <20220618213640.25039-1-ludo@gnu.org> <20220618213832.25165-1-ludo@gnu.org> Date: Thu, 23 Jun 2022 12:05:16 -0400 In-Reply-To: <20220618213832.25165-1-ludo@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Sat, 18 Jun 2022 23:38:31 +0200") Message-ID: <87y1xn2wn7.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1656001011; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=j+qHXjpljw2+Iitx9Om3Glg/6jXKw2zb7ntKs1UCClQ=; b=FI1DKfWuc4ljZBaiiqivZPPxng5EB9LpYjtevtfOF33Q0xcdfrO8UJ/QZPhzYlbGqsel0g UbfXLZ71IxNFO0mqwu/Ac2YV4hj3XHc0T0qHElNs3zForOAYUaEVx7y3FS90FVBDQBr4tv djNJUcVmkU2xYh03/7hyUZcx0cz+wndkxMmer9kn2VPvKoziNmB62OLsZdTk7EFloEyap4 RkAVjMXei7WLNNw+JkNmoLEo+Da4PbaC0l0SHbZRYhiIwAKo17xRoWNii/tHMR5MonJVPi /g3Fqkl5hguGXgFWj+sgswYs/KpvhXfjQCFw+G76/njCtvixdFA4he3Zxei7QQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656001011; a=rsa-sha256; cv=none; b=bOBJcP64wOeroWR+tjZH10aRPkoSVr1pbHJIqKwHLyMQP6IW0Sb50YdxmIJmUOJW+n6Xka 1eT0dVqaY5qldGjWr6vdFa3okf7nWsas11bBI4dViHn7vkCE+NuJJKuURiRON49RjIuEVd GyAVmxp+U+E6FMOywz4sxe+cYv4wVc9CPuh55QtlgWYmXTwD47r+asAzDpV+aHedEAip9C BV3alnmwigapgR0S4QId7cTYiwkTrwyzW7jHmADx5xICFS2bglgVPP85heP5gUlCLdHrfP lXPBZK7a/EdxCaLbEY1sOrcxszgSYtTaFQ5ptExme987H9fG/Dti4DPtiQOT1w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=U5WZPmCt; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=U5WZPmCt; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: F210618849 X-Spam-Score: 5.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: zD+sXVakEaCR Hello, Ludovic Court=C3=A8s writes: > Previously field type errors would be reported in a non-standard way, > and without any source location information. This fixes it. > > * gnu/services/configuration.scm (configuration-field-error): Add a > 'loc' parameter and honor it. Use 'formatted-message' instead of plain > 'format'. > (define-configuration-helper)[field-sanitizer]: New procedure. > Use it. Use STEM as the identifier of the syntactic constructor of the > record type. Add a 'sanitize' property to each field. Remove now > useless STEM macro that would call 'validate-configuration'. > * gnu/services/mail.scm (serialize-listener-configuration): Adjust to > new 'configuration-field-error' prototype. > * tests/services/configuration.scm ("wrong type for a field"): New test. > * po/guix/POTFILES.in: Add gnu/services/configuration.scm. Very nice! I had been meaning to look at what define-configure could be improved w.r.t. the recently added sanitizers; I felt perhaps `define-configure' would perhaps loose its relevance, but I'm happy to see you saw value in upgrading it! The first part LGTM, although I so rarely dabble with syntax-case that it looks a bit alien to my eyes now. [...] > --- a/tests/services/configuration.scm > +++ b/tests/services/configuration.scm > @@ -19,6 +19,7 @@ You forgot to add your copyright notice line. > (define-module (tests services configuration) > #:use-module (gnu services configuration) > + #:use-module (guix diagnostics) > #:use-module (guix gexp) > #:use-module (srfi srfi-34) > #:use-module (srfi srfi-64)) > @@ -43,6 +44,17 @@ (define-configuration port-configuration > 80 > (port-configuration-port (port-configuration))) > > +(test-equal "wrong type for a field" > + '("configuration.scm" 56 11) ;error location > + (guard (c ((configuration-error? c) > + (let ((loc (error-location c))) > + (list (basename (location-file loc)) > + (location-line loc) > + (location-column loc))))) > + (port-configuration > + ;; This is line 55; the test relies on line/column numbers! > + (port "This is not a number!")))) > + It seems fragile to rely on the line/column number, but if we truly need to test that, I don't see a better options. Thanks, Maxim