Repository navigation
Conversation
GitLab issues routable tokens as <prefix><base64-payload>.<token-version>.<payload-length><crc32> which is what both gitlab.com and self-managed instances hand out today. The bridge only matched the legacy shape of an optional "glpat-" prefix followed by exactly 20 base62 characters, so every current token was rejected by the format check in promptToken. Accept both shapes via a validTokenFormat helper, and cover them with table driven tests. The API call in promptToken still decides whether a token actually works, this only catches typos early. Fixes git-bug#1587
This branch has not been deployed
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.
Fixes #1587
Summary
git bug bridge newrejects every personal access token that GitLab issuestoday. The format check in
promptTokenonly accepted the legacy tokenshape:
That is an optional
glpat-prefix followed by exactly 20 base62characters. GitLab now issues routable tokens, which are much longer and
contain dots, so the regex never matches and the validator replies
token has incorrect formatbefore the token is ever sent to the API.The routable token format
Per GitLab's routable tokens design
document:
with a payload of 27 to 300 characters, a two character version, and the
length and crc32 each encoded in base36 on two and seven characters.
This matches tokens reported in the wild by
trufflehog#4551,
collected from both gitlab.com and a self-managed instance:
and the token in the issue report:
Changes
second one for routable tokens.
legacyTokenRe/routableTokenRe, behind avalidTokenFormathelper, mirroring howbridge/githubsplits itslegacyRe/repair.TestValidTokenFormat, a table driven test in the style of theneighbouring
TestProjectPath.The API call in
promptTokenstill decides whether a token actually works.This check only exists to catch typos before a network round trip, so it
stays deliberately shape-only.
Note on the second symptom
The issue also reports
Error: 87:11: illegal character U+002E '.'when theregex is relaxed locally. That message is not produced by the bridge: the
illegal character %#Uwording and theline:columnposition come fromgo-git/gcfg, the git config parser behindgo-git'splumbing/format/config. I could not reproduce it against aconfig written by git-bug -- I round-tripped a
base-urlofhttps://gitlab.mycompany.com/throughrepo.LocalConfig().StoreStringandreopened the repository cleanly. It looks like a separate parsing problem in
the reporter's environment, so I left it alone rather than guess at it.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
The GitLab bridge now accepts routable personal access tokens during interactive setup.
Reviews (1) · Last reviewed commit: "gitlab: accept routable personal access ..." · Reviewed by Greptile