auth: a 429 from the Token Endpoint during refresh deletes a still-valid login
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- go
調査の方向性
internal/auth/uat_client.goから始めてrefreshOnce()を読み、レスポンスのステータスとリフレッシュエラーによって、保存されたトークンを保持するか消去するかがどのように決まるかを確認してください。次に、TestRefreshFailureDeterminesStoredTokenDispositionとスクリプト化されたリフレッシュクライアントを調べ、レスポンスのステータスがどのように表現されているかを確認してください。HTTP 429レスポンスが保存されたトークンを保持したまま再試行され、その動作を網羅する回帰テストがある状態を完了とします。
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- Go
- スター
- 18.2k
- フォーク
- 1.4k
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 18
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
larksuite/cli のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
domain/im
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
bug domain/doc
難易度 1/5 1時間未満 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
mail: all-ASCII draft bodies are hard-wrapped every 998 bytes, inserting newlines inside words and tags対応中かも @linye157 が 26 日前に担当しました。 オープンdomain/mail
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
domain/core enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
github/github-mcp-server#3960 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
JuliusBrussee/caveman#1594 ·
メンテナーはふだん 1 日以内に返信
-
C-bug O-community X-blathers-triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
cockroachdb/cockroach#176264 · コメント 1 件 ·
-
security trivy
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
kubefleet-dev/kubefleet#1068 ·
メンテナーはふだん 3 日以内に返信