Improve error messaging for module submission.

Fixes: https://pagure.io/fm-orchestrator/issue/1098
This commit is contained in:
Joe Talbott
2021-07-22 10:04:10 -04:00
committed by Mike McLean
parent e44d203287
commit 06d31786e8
3 changed files with 9 additions and 5 deletions

View File

@@ -333,11 +333,12 @@ class SCM(object):
with open(path_to_yaml):
return path_to_yaml
except IOError:
log.error(
msg = (
"get_module_yaml: The SCM repository doesn't contain a modulemd file. "
"Couldn't access: %s" % path_to_yaml
)
raise UnprocessableEntity("The SCM repository doesn't contain a modulemd file")
log.error(msg)
raise UnprocessableEntity(msg)
@staticmethod
def is_full_commit_hash(scheme, commit):

View File

@@ -522,8 +522,9 @@ class SCMHandler(BaseHandler):
raise Forbidden("The submitted scmurl %s is not allowed" % url)
if not get_scm_url_re().match(url):
log.error("The submitted scmurl %r is not valid" % url)
raise ValidationError("The submitted scmurl %s is not valid" % url)
msg = "Expected format is '%s?[module-path]#[revision]'" % url
log.error("The submitted scmurl %r is not valid. %s" % (url, msg))
raise ValidationError("The submitted scmurl %s is not valid. %s" % (url, msg))
if not skip_branch and "branch" not in self.data:
log.error("Missing branch")

View File

@@ -1239,7 +1239,9 @@ class TestSubmitBuild:
data = json.loads(rv.data)
assert data["message"] == (
"The submitted scmurl https://src.stg.fedoraproject.org"
"/modules/testmodule.git is not valid"
"/modules/testmodule.git is not valid. Expected format is "
"'https://src.stg.fedoraproject.org/modules/testmodule.git?"
"[module-path]#[revision]'"
)
assert data["status"] == 400
assert data["error"] == "Bad Request"