fix(control-plane): use full namespace path as GitLab repo owner#734
fix(control-plane): use full namespace path as GitLab repo owner#734duboff wants to merge 1 commit into
Conversation
The GitLab provider mapped namespace.path (the last path segment only)
into the repository owner. For nested-group projects
("group/subgroup/project") this returned owner="subgroup", so the
owner/name pairs stored on sessions and returned from listRepositories
could not be resolved back to a project — lookups reconstructed
"subgroup/project" and GitLab returned 404.
Use namespace.full_path, which carries the entire group hierarchy and
equals namespace.path for top-level groups.
📝 WalkthroughWalkthroughGitLab provider methods are updated to reconstruct repository ownership using ChangesGitLab nested-group namespace handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed due to a network error. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/control-plane/src/source-control/providers/gitlab-provider.test.ts (1)
62-83: ⚡ Quick winAdd one nested-group regression test for manual MR URL construction.
You now validate nested owners in fetch/mapping flows, but not in
buildManualPullRequestUrl. Add a test withowner: "acme/backend"to ensure the URL path stays.../acme/backend/web/...(not%2F-collapsed).Also applies to: 385-400, 477-498
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/control-plane/src/source-control/providers/gitlab-provider.test.ts` around lines 62 - 83, Add a regression test in packages/control-plane/src/source-control/providers/gitlab-provider.test.ts that constructs a GitLabSourceControlProvider (new GitLabSourceControlProvider(fakeConfig)) and calls buildManualPullRequestUrl (or the public method that returns the manual MR URL) for a nested-group repo with owner "acme/backend" and name "web" using a PAT auth object; assert the returned URL path contains the un-encoded nested path segment "/acme/backend/web/" (e.g. ends/contains "/acme/backend/web/merge_requests/new") to ensure slashes are not percent-encoded. Ensure the test mirrors the existing nested-group getRepository test setup and uses mockFetch where needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/control-plane/src/source-control/providers/gitlab-provider.ts`:
- Around line 112-116: The change setting owner to data.namespace.full_path
causes owner to include '/' for nested groups, which breaks
buildManualPullRequestUrl because it URL-encodes the whole owner as one segment;
update the URL construction to preserve path separators by splitting owner on
'/' and encode each segment separately (e.g.,
owner.split('/').map(encodeURIComponent).join('/')) and encode the project name
with encodeURIComponent when building the manual MR URL; locate the owner
assignment in gitlab-provider.ts (owner: data.namespace.full_path) and update
buildManualPullRequestUrl to apply per-segment encoding so nested-group paths
produce valid GitLab project URLs.
---
Nitpick comments:
In `@packages/control-plane/src/source-control/providers/gitlab-provider.test.ts`:
- Around line 62-83: Add a regression test in
packages/control-plane/src/source-control/providers/gitlab-provider.test.ts that
constructs a GitLabSourceControlProvider (new
GitLabSourceControlProvider(fakeConfig)) and calls buildManualPullRequestUrl (or
the public method that returns the manual MR URL) for a nested-group repo with
owner "acme/backend" and name "web" using a PAT auth object; assert the returned
URL path contains the un-encoded nested path segment "/acme/backend/web/" (e.g.
ends/contains "/acme/backend/web/merge_requests/new") to ensure slashes are not
percent-encoded. Ensure the test mirrors the existing nested-group getRepository
test setup and uses mockFetch where needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 154a1d97-115c-4497-a9bf-3aa6a7e48327
📒 Files selected for processing (2)
packages/control-plane/src/source-control/providers/gitlab-provider.test.tspackages/control-plane/src/source-control/providers/gitlab-provider.ts
| // full_path, not path: nested groups ("group/subgroup") need the | ||
| // entire namespace so owner/name lookups reconstruct the project path. | ||
| return { | ||
| owner: data.namespace.path, | ||
| owner: data.namespace.full_path, | ||
| name: data.path, |
There was a problem hiding this comment.
Nested-group owner now breaks manual MR URL path composition.
Switching owner to namespace.full_path is correct, but this makes owner contain / for nested groups. buildManualPullRequestUrl currently URL-encodes owner as a single segment, which produces an invalid GitLab project path for nested owners.
💡 Proposed fix
buildManualPullRequestUrl(config: BuildManualPullRequestUrlConfig): string {
- const encodedOwner = encodeURIComponent(config.owner);
+ const encodedOwner = config.owner
+ .split("/")
+ .map((segment) => encodeURIComponent(segment))
+ .join("/");
const encodedName = encodeURIComponent(config.name);
const encodedSource = encodeURIComponent(config.sourceBranch);
const encodedTarget = encodeURIComponent(config.targetBranch);
return (
`https://gitlab.com/${encodedOwner}/${encodedName}/-/merge_requests/new` +
`?merge_request[source_branch]=${encodedSource}` +
`&merge_request[target_branch]=${encodedTarget}`
);
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/control-plane/src/source-control/providers/gitlab-provider.ts`
around lines 112 - 116, The change setting owner to data.namespace.full_path
causes owner to include '/' for nested groups, which breaks
buildManualPullRequestUrl because it URL-encodes the whole owner as one segment;
update the URL construction to preserve path separators by splitting owner on
'/' and encode each segment separately (e.g.,
owner.split('/').map(encodeURIComponent).join('/')) and encode the project name
with encodeURIComponent when building the manual MR URL; locate the owner
assignment in gitlab-provider.ts (owner: data.namespace.full_path) and update
buildManualPullRequestUrl to apply per-segment encoding so nested-group paths
produce valid GitLab project URLs.
Summary
namespace.path— the last path segment only — into the repositoryowneringetRepository,checkRepositoryAccess, andlistRepositories. For nested-group projects (group/subgroup/project) this produced owner=subgroup, so owner/name pairs handed to consumers couldn't be resolved back to a project: lookups reconstructedsubgroup/projectand GitLab returned 404 (surfaced as "Repository is not installed for the GitHub App" at session creation).namespace.full_path, which carries the whole group hierarchy and is identical tonamespace.pathfor top-level groups, so flat-namespace deployments are unaffected.Related: #733 fixes the same nested-group class of bug on the linear-bot side.
Test plan
owneris the full namespace path for nested-group projects across all three methodsfull_path(always present in real GitLab API responses)npm test -w @open-inspect/control-plane— 1291 tests passtsc --noEmitcleanSummary by CodeRabbit