Skip to content

Group import fails when parent_id is passed as int #2506

Closed
@vlizanae

Description

@vlizanae

Description of the problem, including code/CLI snippet

Testing group export/import between different Gitlab instances. Used to the path of the group working as the group id, I tried the following:

gl.groups.import_group(buffer, path='group_slug', name='Group name', parent_id='path/to/parent')

which yields

gitlab.exceptions.GitlabImportError: 400: parent_id is invalid

Not very descriptive but reading gitlab's api docs I find out:

parent_id, integer: ID of a parent group to import the group into. Defaults to the current user’s namespace if not provided.

So I try the numerical id of the group:

gl.groups.import_group(buffer, path='group_slug', name='Group name', parent_id=42)

even worse:

AttributeError: 'int' object has no attribute 'encode'

Expected Behavior

Because the path works as an id in several calls (e.g. groups.get) I think the first version should work. The second version should definitely work.

Actual Behavior

In the end, after digging a bit on the code, what works is:

gl.groups.import_group(buffer, path='group_slug', name='Group name', parent_id='42')

Specifications

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions