ezbz / gitlabber

Gitlabber - clones or pulls entire groups tree from gitlab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failure on empty groups (404 not found)

devstek opened this issue · comments

Hi gitlabbers,

i have the following problem when calling gitlabber on internal gitlab site. I try:

gitlabber -t $TOKEN -u https://git....  -m ssh -i '/foo**' -x '**archive**' /Users/devstek/git

This will result me in an exeception for gitlabber and will fail.

* loading tree: 64.3%|███████████████████████████████████████████████████▍                            | 292/454, group=iot-***Traceback (most recent call last):
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlab/exceptions.py", line 279, in wrapped_f
    return f(*args, **kwargs)
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlab/mixins.py", line 141, in list
    obj = self.gitlab.http_list(path, **data)
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlab/__init__.py", line 656, in http_list
    return GitlabList(self, url, query_data, **kwargs)
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlab/__init__.py", line 784, in __init__
    self._query(url, query_data, **self._kwargs)
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlab/__init__.py", line 789, in _query
    result = self._gl.http_request("get", url, query_data=query_data, **kwargs)
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlab/__init__.py", line 575, in http_request
    response_body=result.content,
gitlab.exceptions.GitlabHttpError: 404: 404 Group Not Found

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

Traceback (most recent call last):
  File "/Users/devstek/Library/Python/3.7/bin//gitlabber", line 8, in <module>
    sys.exit(main())
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlabber/cli.py", line 43, in main
    tree.load_tree()
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlabber/gitlab_tree.py", line 144, in load_tree
    self.load_gitlab_tree()
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlabber/gitlab_tree.py", line 127, in load_gitlab_tree
    self.get_subgroups(group, node)
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlabber/gitlab_tree.py", line 109, in get_subgroups
    subgroups = group.subgroups.list(as_list=False, archived=self.archived)
  File "/Users/devstek/Library/Python/3.7/lib/python/site-packages/gitlab/exceptions.py", line 281, in wrapped_f
    raise error(e.error_message, e.response_code, e.response_body) from e
gitlab.exceptions.GitlabListError: 404: 404 Group Not Found

As a quick workaround and to get it working again, i made a try except block to fix it temporary in gitlab_tree.py

    def get_projects(self, group, parent):
        try:
            projects = group.projects.list(as_list=False, archived=self.archived)
            self.progress.update_progress_length(len(projects))
            self.add_projects(parent, projects)
        except:
            print ("error")

    def get_subgroups(self, group, parent):
        try:
            subgroups = group.subgroups.list(as_list=False, archived=self.archived)
            self.progress.update_progress_length(len(subgroups))
            for subgroup_def in subgroups:
                subgroup = self.gitlab.groups.get(subgroup_def.id)
                subgroup_id = subgroup.name if self.naming == FolderNaming.NAME else subgroup.path
                node = self.make_node(subgroup_id, parent, url=subgroup.web_url)
                self.progress.show_progress(node.name, 'group')
                self.get_subgroups(subgroup, node)
                self.get_projects(subgroup, node)
        except:
            print ("error")

Will you accept pull request for that?

#72 linked with pull request

I think this issue is related, did you receive this error on gitlab foss or gitlab cloud?

This error i got on foss installation of gitlab. problem still exists....

As mentioned in PR,
Have the very same Problem