Public bug reported:
[ Impact ]
glab 1.53.0, as shipped in Ubuntu 26.04, validates tokens locally by
length: api.IsValidToken() accepts only 20-character tokens, 26-character
tokens starting with "glpat-", or 64-character OAuth tokens. GitLab now
issues routable tokens with a variable-length format such as
glpat-<payload>.01.<random>, and some self-managed instances use custom
prefixes (gitlab.gnome.org uses "ggopat"). None of those match the accepted
lengths, so `glab auth status` prints:
✓ Logged in to <host> as <user> (...)
✓ Token: **************************
! Invalid token provided in configuration file.
for every configured host, immediately after a successful authenticated API
call. The token is in fact valid: `glab api user --hostname <host>`,
`glab mr list`, etc. all work. The contradictory warning has misled users
into regenerating tokens or abandoning glab for curl, and it breaks scripts
that treat the line as an authentication failure.
The token-length check was removed upstream in glab 1.66.0 (commit
b5aceab8). Ubuntu 26.04 has no newer glab: the archive is still 1.53.0 and
Debian has not updated it either (Debian wishlist #1128403 asks for 1.69 or
later). Backporting the upstream change is therefore the only way for 26.04
LTS users to get correct output.
[ Test Plan ]
1. On Ubuntu 26.04, configure glab with a GitLab token whose length is not
20, 26 or 64 characters (for example any current gitlab.com routable
token). Run:
glab auth status
Before the update this prints "✓ Logged in ..." followed by
"! Invalid token provided in configuration file." for each host. With the
updated package the warning is gone and the "✓ Logged in" line remains.
`glab api user --hostname gitlab.com` still returns the user JSON.
2. The warning can also be reproduced without a real token by supplying a
55-character dummy token:
GITLAB_TOKEN=$(printf 'x%.0s' {1..55}) glab auth status
Before: "! Invalid token provided in configuration file." is printed.
After: it is not printed. The API call still fails with 401 as expected
for a dummy token.
3. Unit tests:
go test ./api/... ./commands/auth/status/...
[ Where problems could occur ]
* The change only affects the local token-presence check in
`glab auth status`; no API request logic changes. A token consisting only
of whitespace is now treated as absent, which is an improvement.
* The patch replaces the exported api.IsValidToken() helper with
api.IsTokenConfigured(). glab is built as a standalone binary and no
other package in the archive imports its Go packages, so there is no
reverse-dependency impact.
* Output text is unchanged apart from the removed false warning.
[ Other Info ]
* Upstream fix:
https://gitlab.com/gitlab-org/cli/-/commit/b5aceab8ebefbf3a91ace28f4f47ad011bba867d
* The Debian maintainer is preserved in XSBC-Original-Maintainer.
* Debdiff attached.
* To confirm the warning is false, compare with `glab api user --hostname
<host>`, which returns HTTP 200 and the user JSON using the same token.
** Affects: glab (Ubuntu)
Importance: Medium
Status: Confirmed
** Affects: glab (Ubuntu Resolute)
Importance: Medium
Status: Confirmed
** Affects: glab (Ubuntu Stonking)
Importance: Medium
Status: Confirmed
** Affects: glab (Ubuntu Tenacious)
Importance: Medium
Status: Confirmed
** Tags: resolute sru
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2175468
Title:
[SRU] glab: valid routable tokens reported as "Invalid token provided
in configuration file"
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/glab/+bug/2175468/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs