plugin/hub: raise ParameterError for invalid input

Convert the jsonschema.exceptions.ValidationError into the more
appropriate koji.ParameterError.
This commit is contained in:
Christian Kellner 2020-09-13 11:58:12 +02:00 committed by Lars Karlitski
parent 51f55998da
commit 5ba7028340

View file

@ -72,7 +72,10 @@ def osbuildImage(name, version, distro, image_types, target, arches, opts=None,
args = [name, version, distro, image_types, target, arches, opts]
task = {"channel": "image"}
jsonschema.validate(args, OSBUILD_IMAGE_SCHMEA)
try:
jsonschema.validate(args, OSBUILD_IMAGE_SCHMEA)
except jsonschema.exceptions.ValidationError as err:
raise koji.ParameterError(str(err)) from None
if priority and priority < 0 and not context.session.hasPerm('admin'):
raise koji.ActionNotAllowed('only admins may create high-priority tasks')