#2023 Fix the error: 'Project' object has no attribute 'ci_hook'
Merged 8 years ago by pingou. Opened 8 years ago by pingou.

file modified
+4
@@ -15,6 +15,10 @@ 

  import pagure.exceptions

  import pagure.lib

  

+ # This import is needed as pagure.lib relies on Project.ci_hook to be

+ # defined and accessible and this happens in pagure.hooks.pagure_ci

+ from pagure.hooks import pagure_ci  # noqa

+ 

  

  BUILD_STATS = {

      'SUCCESS': ('Build successful', 100),

Since 2.13.1, we were running into this error:
AttributeError: 'Project' object has no attribute 'ci_hook'
on a regular basis, when creating a new PR or when commenting on one, but
not regular comment, just notification.
In both of these situations, and on pagure.io that has the jenkins
integration turned on, we notify the pagure-ci service that there was a
change to the PR that should be tested.

However, nowhere in the code did we load pagure.hooks.pagure_ci which
contains the definition of the PagureCiTable having the backref from
that table to Project and named it ci_hook.
This was working in 2.13 and not in 2.13.1 because in the commit:
867097d
We ran flake8 to clean the pagure.lib module and we removed that import.

Simply bringing back this import and make it ignored of flake8 solves
our problem.

Two things:

  • I have looked at making unit-tests for this but I did not manage to replicate the issue in tests :(

  • This has been hotfixed in prod because it was getting quite annoying :)

rebased

8 years ago

This is one of those trivial bugs which are very annoying so :thumbsup: for this fix.

Thanks for the review :)

rebased

8 years ago

Pull-Request has been merged by pingou

8 years ago