Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI event list fails on None #717

Closed
xarx00 opened this issue Feb 27, 2019 · 3 comments · Fixed by #835
Closed

CLI event list fails on None #717

xarx00 opened this issue Feb 27, 2019 · 3 comments · Fixed by #835

Comments

@xarx00
Copy link
Contributor

xarx00 commented Feb 27, 2019

Description of the problem, including code/CLI snippet

gitlab event list fails in v4/cli.py#l.38 with AttributeError: 'NoneType' object has no attribute 'lower'.

Specifications

  • python-gitlab version: 1.8.0
  • API version you are using (v3/v4): na
  • Gitlab server version (or gitlab.com): na

Cause

The error is caused by the EventManager class in objects.py, because one of _list_filters is called "action". This name collides with the args attribute action, and one of them is probably overwritten. When renaming "action" in _list_filters to something else, gitlab event list continues further (and fails with another similar error).

@xarx00
Copy link
Contributor Author

xarx00 commented Feb 27, 2019

The subsequent error mentioned above is

  File "c:\program files\python27\lib\site-packages\gitlab\v4\cli.py", line 364, in display
    value = value.replace('\r', '').replace('\n', ' ')
AttributeError: 'NoneType' object has no attribute 'replace'

It is caused by that some events on my gilab server do not have "target_title" filled in. Actually, the do not have filled in any relevant attribute, for some reason.

Fix

Fix of the subsequent (NOT the original error):

--- cli.py.orig	2019-02-24 17:37:53.000000000 +0100
+++ cli.py	2019-02-27 19:17:56.045767100 +0100
@@ -357,7 +358,7 @@
                 id = getattr(obj, obj._id_attr)
                 print('%s: %s' % (obj._id_attr.replace('_', '-'), id))
             if hasattr(obj, '_short_print_attr'):
-                value = getattr(obj, obj._short_print_attr)
+                value = getattr(obj, obj._short_print_attr) or 'None'
                 value = value.replace('\r', '').replace('\n', ' ')
                 # If the attribute is a note (ProjectCommitComment) then we do
                 # some modifications to fit everything on one line

@xarx00
Copy link
Contributor Author

xarx00 commented Feb 27, 2019

Fix

In order to fix the primary error of this issue, I had to rename the "action" attribute:
fix.diff.zip

@xarx00 xarx00 changed the title gitlab event list fails on None CLI event list fails on None Mar 1, 2019
@gpocentek
Copy link
Contributor

Hi @xarx00

Could you create a pull request with this change? Thanks.

xarx00 added a commit to xarx00/python-gitlab that referenced this issue Mar 4, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants