Skip to content

Autoupdater fails when user not in found project members

Description

When autoupdater found project to udate it check if current user is in project memebers and has at least developer acces in it. When user is not in the members, autoupdater fails and raises StopIteration exception.

Possible solution

catch StopIteration exception in __check_if_project_can_be_edited method and return False on it.

Logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/autoupdater/gitlab/update.py", line 82, in __get_projects
    project for project in self.__gitlab.projects.list(all=True)
  File "/usr/local/lib/python3.7/site-packages/autoupdater/gitlab/update.py", line 83, in <listcomp>
    if re.fullmatch(project_path, project.attributes['path_with_namespace']) and self.__check_if_project_can_be_edited(project)
  File "/usr/local/lib/python3.7/site-packages/autoupdater/gitlab/update.py", line 75, in __check_if_project_can_be_edited
    user_in_project = next(filter(lambda member: member['username'] == self.__gitlab.user.attributes['username'], project_members))
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/autoupdater", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/autoupdater/commander.py", line 31, in main
    arguments.webhook
  File "/usr/local/lib/python3.7/site-packages/autoupdater/projects/update.py", line 12, in update_projects
    updated_projects = list(repository.update_projects(project_to_update, labels))
  File "/usr/local/lib/python3.7/site-packages/autoupdater/gitlab/update.py", line 112, in update_projects
    for project in self.__get_projects(project_to_update_path):
RuntimeError: generator raised StopIteration
Edited by kszym