From 758f0a0311ed4c817d4bf3d6e65f9c580f109403 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Mar 30 2020 13:03:34 +0000 Subject: don't break on invalid task Fixes: https://pagure.io/koji/issue/2112 --- diff --git a/www/lib/kojiweb/util.py b/www/lib/kojiweb/util.py index ada7f02..90f569f 100644 --- a/www/lib/kojiweb/util.py +++ b/www/lib/kojiweb/util.py @@ -36,6 +36,7 @@ from six.moves import range from six.moves.xmlrpc_client import ProtocolError import koji +import koji.tasks class NoSuchException(Exception): @@ -545,13 +546,14 @@ def taskScratchClass(task_object): """ method = task_object['method'] request = task_object['request'] - if method == 'build' and len(request) >= 3: - # Each task method has its own signature for what gets put in the - # request list. Builds should have an `opts` dict at index 2. - # See www/kojiweb/taskinfo.chtml for the grimoire. - opts = request[2] - if opts.get('scratch'): - return "scratch" + if method == 'build': + try: + opts = koji.tasks.parse_task_params(method, request) + if opts.get('scratch'): + return "scratch" + except Exception: + # not a build or broken task + pass return ""