feat(tracker): GitLab adapter#42
Open
harshitsinghbhandari wants to merge 2 commits into
Open
Conversation
Implements ports.Tracker for GitLab Issues over REST v4. Mirrors the
GitHub adapter pattern (TokenSource, sentinel errors, typed
RateLimitError, atomic+mutex preflight cache, strict provider check)
with GitLab-specific deviations:
- PRIVATE-TOKEN header instead of Authorization: Bearer
- state spelling "opened" (not "open") in query + payload
- rate-limit headers without X- prefix; 429 status
- URL-encoded full project path (subgroups of arbitrary depth)
- assignee_username query param
- label-based closed-reason convention (cancelled/wontfix) since
GitLab REST v4 has no native state_reason/close_reason field
v1 scope: Get, List (single page, no auto-pagination), Preflight.
Comment / Transition deferred to #40; observer/polling to #35.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Zero-config auth per AO-26 directive: a user who has run `glab auth login` gets working credentials with no extra setup. Lookup order is now 1. configured EnvVars (first non-empty wins) 2. GITLAB_TOKEN 3. `glab auth token` 4. else ErrNoToken The glab fallback is on by default — no opt-in flag. Failure (binary missing, not logged in, empty stdout) falls through silently to ErrNoToken so the caller's failure mode stays uniform regardless of whether glab is installed. Stderr is discarded for the same reason: an unauthenticated glab shouldn't print noise during a silent fallthrough. Tests inject a GLAB hook on EnvTokenSource to assert lookup order without touching $PATH. The hook signature matches the parallel `gh auth token` work coming to the GitHub adapter so both auth.go shapes stay parallel. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collaborator
Author
|
Follow-up: added New lookup order in
Properties:
The hook signature mirrors the parallel Tests cover env-var-wins, GITLAB_TOKEN-wins, glab fallback, whitespace trim, glab-error fallthrough, empty-output fallthrough, ctx threading, and a nil-GLAB smoke test. 375 backend tests pass with Still marked do-not-merge pending human review. |
3 tasks
4 tasks
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
Implements
ports.Trackerfor GitLab Issues over REST v4. Read-only v1:Get/List/Preflight. Mirrors the canonical GitHub adapter (TokenSource shape, sentinel errors, typedRateLimitError,atomic.Bool + sync.Mutexpreflight caching, strict provider check) with GitLab-specific deviations called out below.Companion to:
GitLab-specific deviations from the GitHub adapter
Authorization: Bearer <tok>PRIVATE-TOKEN: <tok>(recommended by GitLab)openopened(both in query and payload)X-RateLimit-Remaining,X-RateLimit-ResetRateLimit-Remaining,RateLimit-Reset(noX-prefix)owner/repo#Ngroup/project#iid; subgroups (group/sub/.../project#iid) supported; full project path URL-encoded withurl.PathEscapeassigneeassignee_usernameGET /userGET /userState mapping
GitLab REST v4 does not expose
state_reason/close_reasonon the issue payload, so closed-state disambiguation uses a label convention.opened+ labelin-reviewreview(wins when both status labels are present)opened+ labelin-progressin_progressopened, no status labelopenclosed+ labelcancelledorwontfixcancelledclosed, no cancelled/wontfix labeldoneLabel matching is case-insensitive (GitLab label names are case-insensitive in the UI). The
in-progress/in-reviewlabels match the GitHub adapter verbatim — this is the cross-provider contract. The adapter does NOT write any of these labels in v1.Tests
fakeGLhttptest.Servermirrors GitHub'sfakeGH, recording every call. Unhandled requests fail the test.r.URL.EscapedPath()containing%2F.All 367 backend tests pass with
-race;go vetclean;gofmtclean.Test plan
go test -race ./internal/adapters/tracker/gitlab/...greengo test -race ./...(full module) greengo vet ./...cleangofmt -l backend/internal/adapters/tracker/gitlab/cleanGITLAB_TOKENenv)Out of scope
🤖 Generated with Claude Code