Closed ryan-williams closed 2 months ago
j/w if the comment above was meant for https://github.com/jdalrymple/gitbeaker/issues/3607? I don't see any commits or PRs that appear to address this issue. Thanks!
Im blind haha, disregard my excitment
Okay, following up on this.
You have seemed to have found a hack.
The typing for the .show
method is correct, and while the typing will give you an error when you dont pass a variable (the id) the underlying API apparently allows this behaviour as it defaults to /groups
as opposed to /groups/undefined
. There is nothing wrong with the pagination in the case, since you are not using the method that returns paginated results (as the typing does indicate). For such results use the .all
method. Check the docs for more information.
Steps to reproduce
Attempting to fetch top-level GitLab groups:
This seems to correspond to the underlying GL REST API:
/groups/:id/subgroups
requires an:id
.This works:
5 top-level groups returned
``` [ { id: 7891903, web_url: 'https://gitlab.com/groups/xn--tg8h', name: 'π', path: 'xn--tg8h', description: 'π all geo matters', visibility: 'public', share_with_group_lock: false, require_two_factor_authentication: false, two_factor_grace_period: 48, project_creation_level: 'developer', auto_devops_enabled: null, subgroup_creation_level: 'maintainer', emails_disabled: false, emails_enabled: true, mentions_disabled: null, lfs_enabled: true, math_rendering_limits_enabled: true, lock_math_rendering_limits_enabled: false, default_branch: null, default_branch_protection: 2, default_branch_protection_defaults: { allowed_to_push: [Array], allow_force_push: false, allowed_to_merge: [Array] }, avatar_url: null, request_access_enabled: true, full_name: 'π', full_path: 'xn--tg8h', created_at: '2020-05-09T10:54:58.236Z', parent_id: null, organization_id: 1, shared_runners_setting: 'enabled', ldap_cn: null, ldap_access: null, wiki_access_level: 'enabled' }, { id: 7892291, web_url: 'https://gitlab.com/groups/xn--1g8h', name: 'π', path: 'xn--1g8h', description: 'π', visibility: 'public', share_with_group_lock: false, require_two_factor_authentication: false, two_factor_grace_period: 48, project_creation_level: 'developer', auto_devops_enabled: null, subgroup_creation_level: 'maintainer', emails_disabled: false, emails_enabled: true, mentions_disabled: null, lfs_enabled: true, math_rendering_limits_enabled: true, lock_math_rendering_limits_enabled: false, default_branch: null, default_branch_protection: 2, default_branch_protection_defaults: { allowed_to_push: [Array], allow_force_push: false, allowed_to_merge: [Array] }, avatar_url: null, request_access_enabled: true, full_name: 'π', full_path: 'xn--1g8h', created_at: '2020-05-09T12:22:29.200Z', parent_id: null, organization_id: 1, shared_runners_setting: 'enabled', ldap_cn: null, ldap_access: null, wiki_access_level: 'enabled' }, { id: 12161090, web_url: 'https://gitlab.com/groups/stxnelessi', name: 'π·', path: 'stxnelessi', description: '', visibility: 'public', share_with_group_lock: false, require_two_factor_authentication: false, two_factor_grace_period: 48, project_creation_level: 'developer', auto_devops_enabled: null, subgroup_creation_level: 'maintainer', emails_disabled: false, emails_enabled: true, mentions_disabled: null, lfs_enabled: true, math_rendering_limits_enabled: true, lock_math_rendering_limits_enabled: false, default_branch: null, default_branch_protection: 2, default_branch_protection_defaults: { allowed_to_push: [Array], allow_force_push: false, allowed_to_merge: [Array] }, avatar_url: null, request_access_enabled: true, full_name: 'π·', full_path: 'stxnelessi', created_at: '2021-05-23T09:24:42.900Z', parent_id: null, organization_id: 1, shared_runners_setting: 'enabled', ldap_cn: null, ldap_access: null, wiki_access_level: 'enabled' }, { id: 84541626, web_url: 'https://gitlab.com/groups/eleph9nt', name: 'π', path: 'eleph9nt', description: '', visibility: 'public', share_with_group_lock: false, require_two_factor_authentication: false, two_factor_grace_period: 48, project_creation_level: 'developer', auto_devops_enabled: null, subgroup_creation_level: 'maintainer', emails_disabled: false, emails_enabled: true, mentions_disabled: null, lfs_enabled: true, math_rendering_limits_enabled: true, lock_math_rendering_limits_enabled: false, default_branch: null, default_branch_protection: 2, default_branch_protection_defaults: { allowed_to_push: [Array], allow_force_push: false, allowed_to_merge: [Array] }, avatar_url: null, request_access_enabled: true, full_name: 'π', full_path: 'eleph9nt', created_at: '2024-03-23T11:19:19.505Z', parent_id: null, organization_id: 1, shared_runners_setting: 'enabled', ldap_cn: null, ldap_access: null, wiki_access_level: 'enabled' }, { id: 80003608, web_url: 'https://gitlab.com/groups/siontian', name: 'π£', path: 'siontian', description: '', visibility: 'public', share_with_group_lock: false, require_two_factor_authentication: false, two_factor_grace_period: 48, project_creation_level: 'developer', auto_devops_enabled: null, subgroup_creation_level: 'maintainer', emails_disabled: false, emails_enabled: true, mentions_disabled: null, lfs_enabled: true, math_rendering_limits_enabled: true, lock_math_rendering_limits_enabled: false, default_branch: null, default_branch_protection: 2, default_branch_protection_defaults: { allowed_to_push: [Array], allow_force_push: false, allowed_to_merge: [Array] }, avatar_url: null, request_access_enabled: true, full_name: 'π£', full_path: 'siontian', created_at: '2023-12-23T05:32:52.973Z', parent_id: null, organization_id: 1, shared_runners_setting: 'enabled', ldap_cn: null, ldap_access: null, wiki_access_level: 'enabled' } ] ```corresponding to e.g.:
However, the GitBeaker type definitions think it returns an
ExpandedGroupSchema
, when in this case (quertying the root group) it actually returns aGroupSchema[]
(similar toallSubgroups
).Groups.show
also doesn't take pagination params, according to GitBeaker types, but they are passed through and take effect, in this case. This inconsistency previously confused me re: GitBeaker pagination semantics in general, leading to #3602.Expected behaviour There should be a way to query for top-level groups, with matching type definitions.
Actual behaviour There is only a hack for querying top-level groups (with incorrect type defs).
Possible fixes
Groups.show
Checklist