From patchwork Tue Mar 16 21:05:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Schwartz X-Patchwork-Id: 1884 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [95.216.189.61] by patchwork.archlinux.org with IMAP (fetchmail-6.4.17) for (single-drop); Tue, 16 Mar 2021 21:05:28 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id q9TqJZcdUWB/ZQMAK+/4rw (envelope-from ) for ; Tue, 16 Mar 2021 21:05:27 +0000 Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 0FB4C47EA86; Tue, 16 Mar 2021 21:05:27 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id BDFB92C713; Tue, 16 Mar 2021 21:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.archlinux.org; s=luna; t=1615928726; bh=mfIXIo/f5jvjcoEjwUseZXbjQUoJc52gMuK5Vy+sVJI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=IACAYzoICG8kAK8zfOhpqZGBNaehxlv6oa8uDtplJgd5eqPkKvLfATVKnMk9tws2H JwgJHrbl4+IdZ+2Epjql1YqhsjVyan3mkG0sx76Fj/amIrmZTjA2V5Dbs6OKi4uX8e qLb+K2FUrQSzGlXGSOueaJQbwgjKwvOT+AcEr0KNIHudab2JB3oLY45wD+nnBqZ/Q5 Fe2jiOktOCRNN/9j6PprMP1aCGcqGenV0DB89t+He7JCY3NNIjhy05sPaPV5Tj1+Zs 6rVc6nyGjB1W0qYWMMigzGS0/STa82yYf966+BaCYxHBbpdO1uY1zKv5htJUeC96jD Hzn34U2/vJpbhHBQq1FRQ/qiF5ZuM0am6sEqHT86zJ8keibBYy99+3D1TXuWYmt6zQ pC1caxLyIxkkjLSeUov/bdWvPpXAwbcoGiYApf9+XDe9b8DTb/VDa5cxiA37kUuyLP Dc3xWz0MpWoMyyVwPNlBnxi9s3RkNkTB4m0UFZRYUTgc4pwet64ipOIKuVwbq6Qa08 ++17ReVTCfUCSP5dZfDlmAl3ylDtf9safWDGTEmnhuKprqYjIcA0jfqepjhrE7IG8v skClo5u6zxnHa2nInmsLm5P5ffFbohvBxYyZogTP4X0keeuqITKow8JoKkw2WHa4kb uz38OiG7OSmxLx7Iexd+LP9I= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 0DF7A2C712 for ; Tue, 16 Mar 2021 21:05:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on luna.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_MSPIKE_H4=0.001,RCVD_IN_MSPIKE_WL=0.001, T_DMARC_POLICY_NONE=0.01 autolearn=failed autolearn_force=no version=3.4.4 X-Spam-BL-Results: [127.0.0.19] [127.0.9.2] Received: from mail.archlinux.org (mail.archlinux.org [95.216.189.61]) by luna.archlinux.org (Postfix) with ESMTPS for ; Tue, 16 Mar 2021 21:05:24 +0000 (UTC) To: aur-dev@archlinux.org Subject: [aur-dev][PATCH] git update hook: gracefully error on completely broken .SRCINFO Date: Tue, 16 Mar 2021 17:05:10 -0400 Message-Id: <20210316210510.440738-1-eschwartz@archlinux.org> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-BeenThere: aur-dev@lists.archlinux.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Arch User Repository \(AUR\) Development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Eli Schwartz via aur-dev From: Eli Schwartz Reply-To: "Arch User Repository \(AUR\) Development" Cc: Eli Schwartz Errors-To: aur-dev-bounces@lists.archlinux.org Sender: "aur-dev" Authentication-Results: mail.archlinux.org; dkim=pass header.d=lists.archlinux.org header.s=luna header.b=IACAYzoI; dmarc=pass (policy=none) header.from=archlinux.org; spf=pass (mail.archlinux.org: domain of aur-dev-bounces@lists.archlinux.org designates 5.9.250.164 as permitted sender) smtp.mailfrom=aur-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 0FB4C47EA86 X-Spamd-Result: default: False [3.79 / 15.00]; HAS_REPLYTO(0.00)[aur-dev@lists.archlinux.org]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:5.9.250.164:c]; R_MISSING_CHARSET(2.50)[]; REPLYTO_ADDR_EQ_FROM(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[4]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[lists.archlinux.org:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[archlinux.org,none]; MAILLIST(-0.20)[mailman]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:24940, ipnet:5.9.0.0/16, country:DE]; FROM_NEQ_ENVFROM(0.00)[aur-dev@lists.archlinux.org,aur-dev-bounces@lists.archlinux.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[lists.archlinux.org:s=luna]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[aur-dev]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; MID_RHS_MATCH_TO(1.00)[]; NEURAL_HAM(-0.00)[-1.000]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org I've seen this happen a bunch of times now. Someone cannot push to the AUR, and the error report is some traceback with a KeyError which is difficult to understand without context: remote: Traceback (most recent call last): remote: File "/srv/http/aurweb/aur.git/hooks/update", line 33, in remote: sys.exit(load_entry_point('aurweb==5.0.0', 'console_scripts', 'aurweb-git-update')()) remote: File "/usr/lib/python3.9/site-packages/aurweb-5.0.0-py3.9.egg/aurweb/git/update.py", line 306, in main remote: KeyError: 'pkgbase' Eventually it turns out that their .SRCINFO file is... badly corrupted. Generally, they managed to accidentally commit an *empty* file instead of a .SRCINFO, and in all cases, the problem was on the very first lookup for 'pkgbase'. Point people to the actual failing commit, and have a nicely formatted message indicating that the .SRCINFO is completely invalid. Signed-off-by: Eli Schwartz --- aurweb/git/update.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aurweb/git/update.py b/aurweb/git/update.py index 929b254e..3c9c3785 100755 --- a/aurweb/git/update.py +++ b/aurweb/git/update.py @@ -303,7 +303,11 @@ def main(): # noqa: C901 error['line'], err)) exit(1) - metadata_pkgbase = metadata['pkgbase'] + try: + metadata_pkgbase = metadata['pkgbase'] + except KeyError as e: + die_commit('invalid .SRCINFO, does not contain a pkgbase (is the file empty?)', + str(commit.id)) if not re.match(repo_regex, metadata_pkgbase): die_commit('invalid pkgbase: {:s}'.format(metadata_pkgbase), str(commit.id))