Skip to content

fix(gitlab): add support for nested groups/subgroups#729

Open
wescrow wants to merge 1 commit intokubero-dev:mainfrom
wescrow:fix/gitlab-nested-groups
Open

fix(gitlab): add support for nested groups/subgroups#729
wescrow wants to merge 1 commit intokubero-dev:mainfrom
wescrow:fix/gitlab-nested-groups

Conversation

@wescrow
Copy link

@wescrow wescrow commented Feb 10, 2026

Description

This PR adds support for GitLab repositories organized in nested group structures (e.g., owner/subgroup/repo).

Summary

The existing GitLab integration only handled top-level groups (owner/repo), causing 404 errors when attempting to
connect repositories in nested groups. This was due to incomplete project path encoding in the GitLab API calls.

Changes

  • Added encodeProjectPath() helper method to properly URL-encode all path segments in project paths
  • Fixed getRepository() method to extract the full project path from git URLs instead of just owner/repo
  • Updated API calls in multiple methods to use properly encoded paths:
    • addWebhook() - webhook creation and listing
    • addDeployKey() - deploy key creation
    • getBranches() - branch listing
    • getReferences() - branch, tag, and commit listing

Example

For a repository like git@gitlab.com:owner/subgroup/repo.git:

Before: API call to projects/owner/subgroup%2Frepo → 404 error
After: API call to projects/owner%2Fsubgroup%2Frepo → success

The issue was that forward slashes in the owner path (from nested groups) weren't being encoded, resulting in
malformed API paths.

Fixes #728

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Tested extensively in a production Kubernetes environment:

  1. Built custom Docker image from fork: wescrow/kubero:fix-gitlab-nested-groups
  2. Deployed to Kubernetes cluster running on AWS EKS
  3. Successfully connected GitLab repository in 3-level nested group structure
  4. Verified full workflow:
    • Repository connection and authentication
    • Deploy key creation
    • Webhook configuration
    • Branch listing and selection
    • Application deployment via Runpacks

The fix has been running in production for several hours without issues.

Test Configuration:

  • Kubernetes Version: 1.29+ (AWS EKS)
  • GitLab: gitlab.com (SaaS)
  • Repository: 3-level nested group structure
  • Test Image: wescrow/kubero:fix-gitlab-nested-groups (available on Docker Hub)

Checklist:

  • I removed unnecessary debug logs
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I documented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

GitLab allows repositories to be organized in nested group structures
(e.g., owner/subgroup/repo). The existing code only handled top-level
groups (owner/repo), causing 404 errors when accessing nested repos.

Changes:
- Extract full project path from parsed git URL instead of just owner/repo
- Add encodeProjectPath helper to properly encode all path segments
- Update getRepository, addWebhook, addDeployKey, getBranches, and
  getReferences methods to use the helper for correct API paths

Example: For git@gitlab.com:owner/subgroup/repo.git
- Before: projects/owner%2Frepo (404 error)
- After: projects/owner%2Fsubgroup%2Frepo (success)

Fixes kubero-dev#728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitLab integration fails for repositories in nested groups/subgroups

1 participant