summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-03-16 21:55:58 +0100
committerEli Schwartz <eschwartz@archlinux.org>2021-04-27 19:50:52 +0200
commitc767b13b24e269adbc93db5074ef331f693af091 (patch)
tree776c6d08ba21fddb81f554b95bffbb49f11c525c
parente30621f329b6be05ffb09964390e5839c7650dba (diff)
downloadaur-c767b13b24e269adbc93db5074ef331f693af091.tar.gz
aur-c767b13b24e269adbc93db5074ef331f693af091.tar.xz
git update hook: gracefully error on completely broken .SRCINFO
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 <module> 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 <eschwartz@archlinux.org>
-rwxr-xr-xaurweb/git/update.py6
1 files changed, 5 insertions, 1 deletions
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))