auth: a 429 from the Token Endpoint during refresh deletes a still-valid login
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- authentication
Direzione di ricerca
Inizia da internal/auth/uat_client.go e leggi refreshOnce() per vedere come lo stato della risposta e gli errori di refresh determinano se il token memorizzato viene mantenuto o cancellato. Poi esamina TestRefreshFailureDeterminesStoredTokenDisposition e il client di refresh con risposte predefinite per capire come vengono rappresentati gli stati delle risposte. Il lavoro è completato quando le risposte HTTP 429 vengono ritentate mantenendo il token memorizzato, con un test di regressione che verifichi questo comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When the Token Endpoint answers a user-token refresh with HTTP 429, lark-cli deletes the stored login, even though a rate-limited request was never processed and the refresh token is still valid. The user then has to run auth login again.
We hit this twice in a week on a long-running integration that makes about 10 refreshes a day (one refresh every 2 hours of use). Single, non-concurrent refreshes got two 429 responses in a row, and the token was cleared each time.
Evidence (from ~/.lark-cli/logs/auth-*.log)
time=2026-10-28T10:22:16+01:00 path=/oauth/v3/token status=429 cmdline=lark-cli im +chat-list ...
time=2026-10-28T10:22:17+01:00 path=/oauth/v3/token status=429 cmdline=lark-cli im +chat-list ...
After these two lines, lark-cli auth status reports User identity: missing (no token in keychain ...) and every user call returns token_missing / need_user_authorization. The same happened on 2026-10-22 (two 429s, token cleared). On other days a single 429 was followed by a 200 on the retry, and the login survived.
Cause
internal/auth/uat_client.go, refreshOnce() (v1.0.98) never checks resp.StatusCode:
- A 429 with a non-JSON body (for example plain-text rate-limit text) fails
json.Unmarshal, which returnsrefreshRetryAndClear. - A 429 with a JSON body and an unregistered code goes through
refreshActionForCode(), which returnsrefreshStopAndClearfor unknown codes.
With refreshMaxAttempts = 2, two 429s in a row end in compareAndDeleteStoredToken().
Suggested fix
Treat HTTP 429 as "not processed": retry and preserve the stored token.
// after reading the body, before json.Unmarshal
if resp.StatusCode == http.StatusTooManyRequests {
return refreshResult{
action: refreshRetryAndPreserve,
err: errs.NewNetworkError(errs.SubtypeNetworkTransport,
"token refresh rate limited (HTTP 429); the stored token was preserved").
WithRetryable(),
}
}
And a case for TestRefreshFailureDeterminesStoredTokenDisposition (plus an optional status int field on refreshHTTPTestStep, applied in scriptedRefreshClient):
{
name: "rate limited (HTTP 429) responses preserve after retry",
steps: []refreshHTTPTestStep{
{status: http.StatusTooManyRequests, body: `rate limit exceeded`},
{status: http.StatusTooManyRequests, body: `{"code":99991400,"msg":"request trigger frequency limit"}`},
},
wantCalls: 2,
wantPreserved: true,
wantCategory: errs.CategoryNetwork,
wantSubtype: errs.SubtypeNetworkTransport,
wantRetryable: true,
},
With the current code this case fails (the token is cleared). With the fix it passes, and go test ./internal/auth/... stays green. A backoff before the second attempt would also help, since our two 429s arrived one second apart.
Environment
- lark-cli 1.0.98 (npm), macOS, brand
lark - User identity (UAT), default DPoP mode (
preferred)
- Lingua principale
- Go
- Stelle
- 18.2k
- Fork
- 1.4k
- Merge medio
- 1g 3h
- PR unite (30g)
- 18
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di larksuite/cli
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
domain/im
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug domain/doc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
mail: all-ASCII draft bodies are hard-wrapped every 998 bytes, inserting newlines inside words and tagsForse già presa @linye157 l’ha presa 26 giorni fa. Apertadomain/mail
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
domain/core enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di larksuite/cli
Issue simili
-
test_archive_is_downloaded_after_logout_login doesn't wait for the storage client after loginAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
list_issues and search_issues: inconsistent `fields` allow-lists (`html_url` rejected by list)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
github/github-mcp-server#3960 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
JuliusBrussee/caveman#1594 ·
I maintainer di solito rispondono entro 1 giorno
-
C-bug O-community X-blathers-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
cockroachdb/cockroach#176264 · 1 commento ·
-
security trivy
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
kubefleet-dev/kubefleet#1068 ·
I maintainer di solito rispondono entro 3 giorni