Loading
fix: use correct PAT URL based on GitLab instance version
What does this MR do and why?
Fixes #8377 (closed).
getAccessTokenTip was printing the URL /-/user_settings/personal_access_tokens/legacy/new for all GitLab instances. This URL was introduced in GitLab 19 and returns a 404 on GitLab < 19.
This MR fetches the GitLab instance version via the Metadata API before showing the token prompt. If the major version is < 19, it falls back to the correct URL /-/user_settings/personal_access_tokens. If the version cannot be fetched, it defaults to the /legacy/new URL (safe for GitLab 19+).
MR acceptance checklist
- This MR does not break existing tests
- New test added for
getAccessTokenTipcovering both version branches - No documentation changes needed (no new flags or commands)
How has this been tested?
- Unit tests added for
getAccessTokenTipcovering three cases:- GitLab >= 19: uses
/legacy/newpath - GitLab < 19 (e.g. 18.8): uses
/personal_access_tokenspath - Empty version (fetch failed): falls back to
/legacy/newpath
- GitLab >= 19: uses
- Ran
go test ./internal/commands/auth/login/...— all tests pass - Ran
make lint— 0 issues