IW-558: Percent-encode the GitLab repository slug as one api path segment #563
No reviewers
Labels
No labels
agent-ready
bug
contract
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-human
needs-input
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/iw-cli!563
Loading…
Reference in a new issue
No description provided.
Delete branch "IW-558"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
GitLabClient.encodedRepoescaped one character,/. GitLab's REST API needsthe whole
namespace/projectslug as a single percent-encoded path segment, soevery other URL-significant character passed through raw. A slug carrying
?,#,&,%or a space therefore ended the path or changed its meaning, andthe request addressed a project the caller never named. No exception, no error
message — a wrong request, which is what kept it unnoticed.
encodedReponow percent-encodes the slug as one path segment. One centralchange fixes all four
glab apipath builders; no call site was edited.Defect fixed
Phase 1 —
encodedRepoleaves URL-significant characters raw in fourglab apipaths (#561, merged)The four affected builders:
buildPipelineJobsCommand—projects/…/pipelines/$id/jobsbuildMergeRequestCommand—projects/…/merge_requests/$nbuildJobTraceCommand—projects/…/jobs/$id/tracebuildMergeRequestForBranchCommand— the worst of the four, because the slugprecedes a real query string, so a slug-borne
&or?merged intoparameters that already existed
The fix uses
URLEncoder.encode(repository, "UTF-8").replace("+", "%20"). The.replacestep is required:URLEncoderis form-encoding, so a space wouldotherwise arrive as
+, which means a literal plus inside a path.Scope held
encodedQueryValueand the four--repobuilders are untouched. Those hand therepository to glab as a raw process argument, never into a path this code
builds, so encoding them would change what glab receives for no reason this
issue names.
Testing
Two regression tests in
core/test/GitLabCiTest.scala, both proved RED beforebeing accepted:
slug
group/pro?a=1&b#x%z wthroughbuildMergeRequestCommand.drives the same slug through
buildMergeRequestForBranchCommandand pins theencoded segment against the
?source_branch=that follows it.No-regression proof: the existing assertions pinning
group%2Fsub%2Fprojectpass unchanged. Full percent-encoding is byte-identical to
/-only escaping fora legal slug, so the fix carries no risk for a correctly configured project.
./iw ./test unit→ exit 0 (core.test 186/186, dashboard.test 241/241)./iw ./test lint→ exit 0Code review: 1 iteration, 0 critical, 0 warnings.
Release notes
project-management/issues/IW-558/release-notes.md(Czech, user-facing).Follow-up
Filed as #562 —
GitRemote.extractRepositoryPathand the config parserdisagree on which characters a repository slug may hold.
Closes #558
🤖 Generated with Claude Code
Issue: IW-558 Phase: 1 - encodedRepo leaves URL-significant characters raw in four glab api paths This commit marks the checkpoint for phase 1 context generation. Use dx-fix IW-558 to return to this point. 🤖 Generated with Claude Code Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>encodedRepo leaves URL-significant characters raw in four glab api paths Artifacts: - phase-01-tasks.md 🤖 Generated with Claude Code Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>