#1724 Improve error messaging for module submission.
Merged 2 years ago by mikem. Opened 2 years ago by josepht.
josepht/fm-orchestrator issue-1098  into  master

@@ -333,11 +333,12 @@ 

              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):

@@ -501,8 +501,9 @@ 

              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")

file modified
+3 -1
@@ -1239,7 +1239,9 @@ 

          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"