Skip to content

CLI event list fails on None #717

Closed

Description

@xarx00

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

Activity

  1. xarx00 commented on Feb 27, 2019

    @xarx00
    ContributorAuthor

    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
    
  2. xarx00 commented on Feb 27, 2019

    @xarx00
    ContributorAuthor

    Fix

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

  3. changed the title [-]gitlab event list fails on None[/-] [+]CLI event list fails on None[/+] on Mar 1, 2019
  4. gpocentek commented on Mar 3, 2019

    @gpocentek
    Contributor

    Hi @xarx00

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

  5. added a commit that references this issue on Mar 4, 2019
  6. added a commit that references this issue on Jul 21, 2019
    8d1552a
  7. locked as resolved and limited conversation to collaborators on Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions