#2314 changing logic order to avoid error with no ci. Fixes #2312
Merged by tflink. Opened by tflink.
tflink/pagure feature/2312-fix-pr-when-no-ci  into  master

Download 2314.patch

This is a simple change to short-circuit the if statement if pagure-ci is not configured. I can't run the unit tests right now but when I test this in a deployment, it solves the 500 problem when a PR is created in a pagure instance without pagure-ci configured

It might be good to write a test for this if you are later able to get the tests running. LGTM otherwise.

In pagure/lib/__init__.py there are many other lines using the same code, maybe same fix should be applied?

Besides, pingou fixed same error in https://pagure.io/pagure/pull-request/2023. Compare the two fixtures, which one do you prefer?

In pagure/lib/init.py there are many other lines using the same code, maybe same fix should be applied?

Yeah, it probably should. I'll update the PR.

Besides, pingou fixed same error in https://pagure.io/pagure/pull-request/2023. Compare the two fixtures, which one do you prefer?

That was merged 2 months ago and is running in my instance but I'm still hitting this error. Either something isn't set up right on my end or it wasn't a 100% fix. Are there other non-test instances running without pagure-ci?

1 new commit added

  • changing order for other PAGURE_CI comparisons

Ok so this is a case of import chain.

Basically, we have:

pagure/api/ci/jenkins.py:import pagure.lib.lib_ci as lib_ci

and then we have:

pagure/lib/lib_ci.py:from pagure.hooks import pagure_ci  # noqa: E402,F401

So the combination of the two should fixes the missing ci_hook attribute, but the trick is that the import of pagure.api.ci.jenkins at:

pagure/api/__init__.py:    from pagure.api.ci import jenkins  # noqa: E402

is conditioned by:

if pagure.APP.config.get('PAGURE_CI_SERVICES', False):

So if there are no PAGURE_CI_SERVICES defined the import chain is busted, thus the error that @tflink is seeing.

Going to merge this PR manually then, thanks @tflink !

Commit ad88b330 fixes this pull-request

Pull-Request has been merged by tflink@fedoraproject.org

Metadata