fix(pr_create): support GitLab nested groups + add regression test#400
Merged
bakeb7j0 merged 1 commit intokahuna/390-bug-drainfrom May 5, 2026
Merged
Conversation
… flag Two bugs in pr_create against GitLab projects with nested groups (#290): 1. The `repo` regex `^[a-zA-Z0-9._-]+/[a-zA-Z0-9._-]+$` rejected group/subgroup/.../repo paths before they reached the platform adapter, breaking pr_create on every nested-group GitLab project (`analogicdev/internal/tools/blueshift/blueshift-docmancer-ui` was the failing reproducer — 4 `/` levels). 2. The post-create verify step shelled to `glab mr view -F json`, but `-F` is not a flag on any glab subcommand in 1.36.0. The MR was being created server-side then the verify step would error, leaving callers to clean up duplicates. Bug 2 was already fixed by #386 (a5cf34c) on the kahuna branch — the post-create lookup now uses `glab api projects/<encoded>/merge_requests ?source_branch=<head>&state=opened` and parses the JSON in-process. This commit adds a regression test for the nested-group path through that adapter. Bug 1 fix: - Add `lib/schemas/repo.ts` as the single source of truth for the slug regex. New pattern: `^[a-zA-Z0-9._-]+(/[a-zA-Z0-9._-]+)+$` — accepts arbitrary `/` depth while still rejecting bare `owner` (no `/`), empty segments (`a//b`), and shell metacharacters. - Update all 19 handlers that ship a `repo` parameter (`pr_*`, `ci_*`, `wave_init`, `wave_reconcile`, `label_*`, `work_item`) to import `repoOptionalSchema` from the shared module instead of rolling their own regex. - Add `lib/schemas/repo.test.ts` covering flat slugs, nested-group slugs (including the exact #290 reproducer), and rejection of malformed input. - Add a nested-group regression test in `pr-create-gitlab.test.ts` asserting the slug forwards verbatim to `-R` and URL-encodes every `/` as `%2F` for the api lookup path. GitHub-side adapters keep their flat `GITHUB_REPO_SLUG` defence- in-depth regex — that's a platform constraint, not a relaxation target. All 2175 unit tests pass; full ci/validate.sh green. Closes #290
This was referenced May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes for GitLab pr_create against nested-group projects:
analogicdev/internal/tools/blueshift/blueshift-docmancer-ui(4 levels) now validates. Previously^[a-zA-Z0-9._-]+/[a-zA-Z0-9._-]+$only allowedowner/repo.glab mr view -F jsonflag (already fixed by fix(pr-create-gitlab): replace broken glab mr view -F json with glab api lookup #386 on kahuna; this guards against reintroduction).Changes
lib/schemas/repo.ts— single-source-of-truthREPO_SLUG_REGEX,repoSchema,repoOptionalSchemalib/schemas/repo.test.ts— 35 tests covering flat slugs, nested groups (up to 7 levels), malformed input rejectionrepoOptionalSchemainstead of inline regex (pr_, ci_, label_, wave_, work_item)lib/adapters/pr-create-gitlab.test.tsfor nested-group + URL-encoded%2FhandlingTests
./scripts/ci/validate.shgreenGITHUB_REPO_SLUGin GitHub adapters left intact (platform constraint preserved)Notes
The wave plan called out
lib/adapters/gitlab/pr-create.tsbut the actual codebase uses the flatlib/adapters/pr-create-gitlab.tslayout (file naming differs from plan, behaviour identical).Closes #290