#1058 Surface an error to the user when no base module could be found in the module's buildrequires
Merged 5 years ago by mprahl. Opened 5 years ago by mprahl.

@@ -251,8 +251,10 @@ 

      # Get the MMDs of all compatible base modules based on the buildrequires.

      base_module_mmds = _get_base_module_mmds(mmd)

      if not base_module_mmds:

-         raise ValueError("No base module found in buildrequires section of %s" % ":".join(

-             [mmd.get_name(), mmd.get_stream(), str(mmd.get_version())]))

+         base_module_choices = ' or '.join(conf.base_module_names)

+         raise UnprocessableEntity(

+             "None of the base module ({}) streams in the buildrequires section could be found"

+             .format(base_module_choices))

  

      # Add base modules to `mmds`.

      for base_module in base_module_mmds:

@@ -0,0 +1,38 @@ 

+ document: modulemd

+ version: 2

+ data:

+   summary: A test module in all its beautiful beauty

+   description: >-

+     This module demonstrates how to write simple modulemd files And can be used for

+     testing the build and release pipeline.

+   license:

+     module:

+     - MIT

+   dependencies:

+   - buildrequires:

+       platform: [Go]

+     requires:

+       platform: [Sox]

+   references:

+     community: https://docs.pagure.org/modularity/

+     documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules

+   profiles:

+     default:

+       rpms:

+       - tangerine

+   api:

+     rpms:

+     - perl-Tangerine

+     - tangerine

+   components:

+     rpms:

+       perl-List-Compare:

+         rationale: A dependency of tangerine.

+         ref: master

+       perl-Tangerine:

+         rationale: Provides API for this module and is a dependency of tangerine.

+         ref: master

+       tangerine:

+         rationale: Provides API for this module.

+         ref: master

+         buildorder: 10

@@ -802,6 +802,23 @@ 

  

      @patch('module_build_service.auth.get_user', return_value=user)

      @patch('module_build_service.scm.SCM')

+     def test_submit_build_no_base_module(self, mocked_scm, mocked_get_user):

+         FakeSCM(mocked_scm, 'testmodule', 'testmodule-no-base-module.yaml',

+                 '620ec77321b2ea7b0d67d82992dda3e1d67055b4')

+ 

+         rv = self.client.post('/module-build-service/2/module-builds/', data=json.dumps(

+             {'branch': 'master', 'scmurl': 'git://pkgs.stg.fedoraproject.org/modules/'

+                 'testmodule.git?#68931c90de214d9d13feefbd35246a81b6cb8d49'}))

+         data = json.loads(rv.data)

+         assert data == {

+             'status': 422,

+             'message': ('None of the base module (platform) streams in the buildrequires section '

+                         'could be found'),

+             'error': 'Unprocessable Entity'

+         }

+ 

+     @patch('module_build_service.auth.get_user', return_value=user)

+     @patch('module_build_service.scm.SCM')

      @patch('module_build_service.config.Config.rebuild_strategy_allow_override',

             new_callable=PropertyMock, return_value=True)

      def test_submit_build_rebuild_strategy(self, mocked_rmao, mocked_scm, mocked_get_user):

This used to result in an exception that was not caught by Flask. This PR changes the exception and makes it a little more user friendly so that the user knows why the module build failed.

+1, I see tests failed because of some infra issue, can you re-run it? Feel free to just merge it if they pass.

rebased onto 2a1c9c0a55cf4b0121211f53793948ed53dbf0ed

5 years ago

rebased onto 85401c2

5 years ago

The tests are passing locally. I submitted a ticket to get the infra issue fixed:
https://pagure.io/fedora-infrastructure/issue/7332

Pull-Request has been merged by mprahl

5 years ago