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 wO/4H8MMwmEC5AAAgWs5BA (envelope-from ) for ; Tue, 21 Dec 2021 18:20:03 +0100 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 mLfVG8MMwmHCVQAA1q6Kng (envelope-from ) for ; Tue, 21 Dec 2021 17:20:03 +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 07B2E21D24 for ; Tue, 21 Dec 2021 18:20:03 +0100 (CET) Received: from localhost ([::1]:34108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzinx-0004pQ-Po for larch@yhetil.org; Tue, 21 Dec 2021 12:20:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzim2-0002A9-Vm for bug-guix@gnu.org; Tue, 21 Dec 2021 12:18:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:43892) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzim2-0002wX-Kv for bug-guix@gnu.org; Tue, 21 Dec 2021 12:18:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mzim2-00058K-Dp for bug-guix@gnu.org; Tue, 21 Dec 2021 12:18:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#52577: =?UTF-8?Q?=E2=80=98guix_?= =?UTF-8?Q?lint=E2=80=99?= throws an ugly backtrace if the GitHub updater receives =?UTF-8?Q?=E2=80=9Crate?= limit =?UTF-8?Q?exceeded=E2=80=9D?= error Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 21 Dec 2021 17:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52577 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Maxime Devos , 52577@debbugs.gnu.org Received: via spool by 52577-submit@debbugs.gnu.org id=B52577.164010704119673 (code B ref 52577); Tue, 21 Dec 2021 17:18:02 +0000 Received: (at 52577) by debbugs.gnu.org; 21 Dec 2021 17:17:21 +0000 Received: from localhost ([127.0.0.1]:55438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzilM-00057F-TR for submit@debbugs.gnu.org; Tue, 21 Dec 2021 12:17:21 -0500 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:60574 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mzilK-00056w-8M for 52577@debbugs.gnu.org; Tue, 21 Dec 2021 12:17:19 -0500 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yoctocell.xyz; s=mail; t=1640107030; bh=/PNaqzix59fck2dHV8VMOA8fspL+dogJ7Z/UNqerhL8=; h=From:To:Subject:In-Reply-To:References:Date; b=dd9wkexiw6POoFJktSR3zZhh4tciSc2ebdLwnWiVI2bz+Pk6vhpnMrJadpDjZZuej P7UwbUeb9ZAwtDfbCKBkVOm125S4FQQOKM3qRh1n1SQztM+SGkyyTDC67rLC4rpvZ0 NIQB3JqS8s2JX0m4YOvE9wFpom9PnyLUkd1SVaEk= In-Reply-To: <80e40710ed0814ecded0d7f153d1e1ef6e30a311.camel@telenet.be> References: <87bl1fjpl3.fsf@disroot.org> <746d29cab94d0a8686283a896cd2f639523e9d5d.camel@telenet.be> <87sfurhru8.fsf@disroot.org> <80e40710ed0814ecded0d7f153d1e1ef6e30a311.camel@telenet.be> Date: Tue, 21 Dec 2021 18:17:08 +0100 Message-ID: <87wnjxev3f.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640107203; 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:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=/PNaqzix59fck2dHV8VMOA8fspL+dogJ7Z/UNqerhL8=; b=e+FBnHA2koh3jcGlYMBoO7p/Aq2q/TT/AgUfE7oLrAEudch4n+0AyrxUsNRCRtww5b2I1y HV1xAJ0WVquwg2chgpsnrCRMfqhpWRJzIriG0acE1Jb46PLhxpHFUXGFTEGzt83d3/zT+J DMz53n8zCWisjjekE4oH1lJjdcpUr6vIAmH1+fhR4mFPsTmhCgVgraKH9QL/EqfQ8Kn1js mG3hHMXPHwBhRBWYBVYvIbRRoxSgxXqq5foOZRunSvNjw0jgoPTixgAG9NT4+dD2va5k66 8xbHeO285XHJlk21a1m25uKutCQnLkutPW+TC8z1pQg+x7+UeUkRacquwec8UQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640107203; a=rsa-sha256; cv=none; b=MfIEbAC6zyh7NsvME1JBbGST145webeFrUmuaaYbkDyWV28p3cfZin4Kai2CBWyu7XtRyQ zwy8nJJeW79P0SXvwHIEqFH8sYtcpdYJyoTV4jmeqUSRhpLYb4D1zMfXwHZ7k/nIZGkBSI giuwXrL02mLFJS9kQsSrpumswnL1L1nsAhS8NM36EjfMy/IHBx3EG0U19xc+Sj86yjsC+l +hDLGN9VQH97cleD+boLXLaLaG7SJAfOSG5NqR5iRZ9FlE+VAw5QBRFxeLpRqKtzJ1flZa G43c84n6w7KhzGX9Vpdt/CmZd9tydaXG4ELv9OsM9/+uR236VlrAMAsIaPZnUw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=dd9wkexi; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.33 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=dd9wkexi; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 07B2E21D24 X-Spam-Score: -5.33 X-Migadu-Scanner: scn0.migadu.com X-TUID: D/xU0opoc7nE --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On So, Dez 19 2021, Maxime Devos wrote: > Xinglu Chen schreef op vr 17-12-2021 om 21:57 [+0100]: >> On Fri, Dec 17 2021, Maxime Devos wrote: >>=20 >> > Xinglu Chen schreef op vr 17-12-2021 om 15:03 [+0100]: >> > > (guard (c ((and (http-get-error? c) >> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 (string=3D? "rate limit exceeded" >> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (http-get-error-reason c))) >> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (warnin= g (G_ "GitHub rate limit exceeded")) >> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #f)) >> > > =C2=A0 (with-networking-fail-safe ...)) >> >=20 >> > Shouldn't this be wrapped the other way around? >> > Or maybe even move the http-get-error?+string=3D?+warning inside >> > call-with-networking-fail-safe? >>=20 >> Thanks for the pointer, it seems that =E2=80=98throw=E2=80=99 in >> =E2=80=98call-with-networking-fail-safe=E2=80=99 wraps the original exce= ption an >> additional =E2=80=98&compound-exception=E2=80=99.=C2=A0 Before the =E2= =80=98throw=E2=80=99, the exception >> looks like this: >>=20 >> --8<---------------cut here---------------start------------->8--- >> (%exception #<&compound-exception components: (#<&http-get-error uri: >> #< scheme: https userinfo: #f host: "api.github.com" port: #f >> path: "/repos/PipeWire/pipewire/releases" query: #f fragment: #f> >> code: 403 reason: "rate limit exceeded"> #<&message message: " >> https://api.github.com/repos/PipeWire/pipewire/releases: HTTP >> download failed: 403 (\"rate limit exceeded\")">)>) >> --8<---------------cut here---------------end--------------->8--- >>=20 >> After the =E2=80=98throw=E2=80=99, it becomes this: >>=20 >> --8<---------------cut here---------------start------------->8--- >> #<&compound-exception components: (#<&error> #<&irritants irritants: >> (#<&compound-exception >> components: (#<&http-get-error uri: #< scheme: https userinfo: >> #f host: >> "api.github.com" port: #f path: "/repos/PipeWire/pipewire/releases" >> query: #f fragment: #f> >> code: 403 reason: "rate limit exceeded"> #<&message message: >> "https://api.github.com/repos/PipeWire/pipewire/releases: HTTP >> download failed: 403 (\"rate >> limit exceeded\")">)>)> #<&exception-with-kind-and-args kind: >> %exception args: >> (#<&compound-exception components: (#<&http-get-error uri: #< >> scheme: https userinfo: >> #f host: "api.github.com" port: #f path: >> "/repos/PipeWire/pipewire/releases" query: #f >> fragment: #f> code: 403 reason: "rate limit exceeded"> #<&message >> message: >> "https://api.github.com/repos/PipeWire/pipewire/releases: HTTP >> download failed: 403 (\"rate >> limit exceeded\")">)>)>)> >> --8<---------------cut here---------------end--------------->8--- >>=20 >> This means that the =E2=80=98guard=E2=80=99 form in =E2=80=98call-with-n= etworking-fail-safe=E2=80=99 >> is >> never going to match anything since the real exception will always be >> nested >> in another =E2=80=98&compound-exception=E2=80=99. > > Actually, being wrapped in &compound-exception shouldn't be a problem: > &compound-exception just means that the exception is of multiple types, > e.g. both &message and &http-get-error or something like that. In that > case, the exception could be both message? and http-get-error?. > > I think the problem is, that for some unknown reason, the > &http-get-error/&message exception gets wrapped in a > &exception-with-and-args --- I guess there's a bad interaction with > the throw/catch exception handling system and the raise/guard system, > because only 'system-error'/'tls-certificate-error'/...-style > exceptions should get wrapped in a &exception-with-kind-and-arguments. Yeah, the catch/throw system doesn=E2=80=99t really work well with =E2=80= =98raise=E2=80=99. Here is what I found after some digging: (catch KIND THUNK HANDLER) uses =E2=80=98exception-kind=E2=80=99 to determi= ne the kind of the exception. Since =E2=80=98&http-get-error=E2=80=99 was created usin= g =E2=80=98raise=E2=80=99, it doesn=E2=80=99t really have a notion of a =E2=80=9Ckind=E2=80=9D, therefore= , =E2=80=98exception-kind=E2=80=99 returns the =E2=80=98%exception=E2=80=99 symbol. I guess that=E2=80=99s wh= y I had to match on ('%exception exception) to match the =E2=80=98&http-get-error=E2=80=99 Excerpt from the patch I attached: (catch #t proc (match-lambda* ... ((and ('%exception exception) (http-get-error? exception)) ...) ...)) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lint-Fix-handling-of-HTTP-errors.patch Content-Transfer-Encoding: quoted-printable From=20cf1f08ba8f4c9866ab0077cc50941133ba4ff77b Mon Sep 17 00:00:00 2001 Message-Id: From: Xinglu Chen Date: Fri, 17 Dec 2021 21:32:51 +0100 Subject: [PATCH] lint: Fix handling of HTTP errors. MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit The 'catch' call would wrap the '&http-get-error' error in an '%exception' meaning that the 'guard' form would never catch a '&http-get-error'. It se= ems that the throw/catch system doesn't play nicely with the raise/guard system. * guix/lint.scm (call-with-networking-fail-safe): Add pattern to match '&http-get-error'; handle GitHub rate limit error; remove 'guard' form. Fixes: =2D-- guix/lint.scm | 80 ++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/guix/lint.scm b/guix/lint.scm index 403f343b6c..67b2bb7221 100644 =2D-- a/guix/lint.scm +++ b/guix/lint.scm @@ -801,43 +801,51 @@ (define response (define (call-with-networking-fail-safe message error-value proc) "Call PROC catching any network-related errors. Upon a networking error, display a message including MESSAGE and return ERROR-VALUE." =2D (guard (c ((http-get-error? c) =2D (warning (G_ "~a: HTTP GET error for ~a: ~a (~s)~%") =2D message =2D (uri->string (http-get-error-uri c)) =2D (http-get-error-code c) =2D (http-get-error-reason c)) =2D error-value)) =2D (catch #t =2D proc =2D (match-lambda* =2D (('getaddrinfo-error errcode) =2D (warning (G_ "~a: host lookup failure: ~a~%") =2D message =2D (gai-strerror errcode)) =2D error-value) =2D (('tls-certificate-error args ...) =2D (warning (G_ "~a: TLS certificate error: ~a") =2D message =2D (tls-certificate-error-string args)) =2D error-value) =2D (('gnutls-error error function _ ...) =2D (warning (G_ "~a: TLS error in '~a': ~a~%") + (catch #t + proc + (match-lambda* + (('getaddrinfo-error errcode) + (warning (G_ "~a: host lookup failure: ~a~%") + message + (gai-strerror errcode)) + error-value) + (('tls-certificate-error args ...) + (warning (G_ "~a: TLS certificate error: ~a") + message + (tls-certificate-error-string args)) + error-value) + (('gnutls-error error function _ ...) + (warning (G_ "~a: TLS error in '~a': ~a~%") + message + function (error->string error)) + error-value) + ((and ('system-error _ ...) args) + (let ((errno (system-error-errno args))) + (if (member errno (list ECONNRESET ECONNABORTED ECONNREFUSED)) + (let ((details (call-with-output-string + (lambda (port) + (print-exception port #f (car args) + (cdr args)))))) + (warning (G_ "~a: ~a~%") message details) + error-value) + (apply throw args)))) + ((and ('%exception exception) + (http-get-error? exception)) + (cond + ((and (string-contains (uri->string (http-get-error-uri exception)) + "api.github.com") + (string=3D? (http-get-error-reason exception) + "rate limit exceeded")) + (warning (G_ "GitHub rate limit exceeded"))) + (else + (warning (G_ "~a: HTTP GET error for ~a: ~a (~s)~%") message =2D function (error->string error)) =2D error-value) =2D ((and ('system-error _ ...) args) =2D (let ((errno (system-error-errno args))) =2D (if (member errno (list ECONNRESET ECONNABORTED ECONNREFUSED)) =2D (let ((details (call-with-output-string =2D (lambda (port) =2D (print-exception port #f (car args) =2D (cdr args)))))) =2D (warning (G_ "~a: ~a~%") message details) =2D error-value) =2D (apply throw args)))) =2D (args =2D (apply throw args)))))) + (uri->string (http-get-error-uri exception)) + (http-get-error-code exception) + (http-get-error-reason exception)))) + error-value) + (args + (apply throw args))))) =20 (define-syntax-rule (with-networking-fail-safe message error-value exp ...) (call-with-networking-fail-safe message error-value base-commit: 6718fe7e872e78f8f15dd596fcf15c594a039bfe =2D-=20 2.33.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmHCDBQVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x52w0P/j8NKqkIe4LASba9xKOtajkPqmnX bSEN/Uu0rQdOPSuFdsNEZxPEOva4EQsDVj0tgatq9dfq7fXMQ340U/OGsCvyqnce 3cwhpEAV/15nQ1UK1nw9oSDB83T2JxKpy+Gbw17LEp58LqCXduNt6h+jGwTlArmv NMmZWd32+dNiCbqHZeIJ5LBIpFfi1DGvdBiO8ijUGryhF/4IR7sf9jrHV/GixRje dd7P2S7p46e+030/iC6ZD7UGikKUi01+cQIo8wYIHI8Mm0AYiOnnPWd4W9tSi3RP e59fl36G3fgxAWnj1xxQba7V/dOrzRAk3FWp+3DT+n1cHF8nstBLVJy4CPsouyQk NmfWnjC2vKAzbLy4PCeAs6Fwbv9iwxdAOcrLkh8J7YBdOf4tWs+mIbbtDVXOiyws LYUFuRWEpFV30JintJHjcTtCP7pkRYTKvgR0RQFjE/sbCfjkaOfg0HZDWMB5p6ax jyJb+l1OHK6CloOAvSuIsrxjSiqYANXSI9rm4Yan9kCD3AsD8PVLp7RxE/O1oqEO Dgaie+BaH0KVlV+OGAMDaViq0wbJlD8qo2UUP9prtIK7R1oBDjh78Yo2RFRJnrKm koKUbxDaag9LIB48Sdkk+TBBGkbKU/04RXNOwu2W89TdGMcFlyhNHtsJEU9yzpVG INX5OGLKMMepYR+8 =bA40 -----END PGP SIGNATURE----- --==-=-=--