auth: a 429 from the Token Endpoint during refresh deletes a still-valid login
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- authentication
Línea de trabajo
Empieza por internal/auth/uat_client.go y lee refreshOnce() para ver cómo el estado de la respuesta y los errores de actualización determinan si se conserva o se borra el token almacenado. Después, inspecciona TestRefreshFailureDeterminesStoredTokenDisposition y el cliente de actualización con respuestas programadas para ver cómo se representan los estados de respuesta. El objetivo se cumple cuando se reintentan las respuestas HTTP 429 y se conserva el token almacenado, con una prueba de regresión que cubra este comportamiento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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)
- Lenguaje dominante
- Go
- Estrellas
- 18.2k
- Forks
- 1.4k
- Merge medio
- 1 d 3 h
- PR fusionados (30 d)
- 18
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de larksuite/cli
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
domain/im
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug domain/doc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
mail: all-ASCII draft bodies are hard-wrapped every 998 bytes, inserting newlines inside words and tagsPosiblemente ocupada @linye157 la tomó hace 26 días. Abiertodomain/mail
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Los mantenedores suelen responder en 1 día
-
domain/core enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
Todos los issues de larksuite/cli
Issues similares
-
test_archive_is_downloaded_after_logout_login doesn't wait for the storage client after loginAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
list_issues and search_issues: inconsistent `fields` allow-lists (`html_url` rejected by list)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
github/github-mcp-server#3960 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
JuliusBrussee/caveman#1594 ·
Los mantenedores suelen responder en 1 día
-
C-bug O-community X-blathers-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
cockroachdb/cockroach#176264 · 1 comentario ·
-
security trivy
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
kubefleet-dev/kubefleet#1068 ·
Los mantenedores suelen responder en 3 días