auth: a 429 from the Token Endpoint during refresh deletes a still-valid login
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- authentication
Hướng nghiên cứu
Bắt đầu với internal/auth/uat_client.go và đọc refreshOnce() để xem trạng thái phản hồi và lỗi làm mới quyết định việc giữ lại hay xóa token đã lưu như thế nào. Sau đó, kiểm tra TestRefreshFailureDeterminesStoredTokenDisposition và client làm mới được lập kịch bản để biết trạng thái phản hồi được biểu diễn ra sao. Công việc hoàn tất khi các phản hồi HTTP 429 được thử lại trong khi token đã lưu vẫn được giữ nguyên, kèm theo một kiểm thử hồi quy bao quát hành vi này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- Go
- Star
- 18.2k
- Fork
- 1.4k
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 18
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của larksuite/cli
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
domain/im
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug domain/doc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
mail: all-ASCII draft bodies are hard-wrapped every 998 bytes, inserting newlines inside words and tagsCó thể đã có người làm @linye157 đã nhận 26 ngày trước. Đang mởdomain/mail
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
domain/core enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của larksuite/cli
Issue tương tự
-
test_archive_is_downloaded_after_logout_login doesn't wait for the storage client after loginĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
list_issues and search_issues: inconsistent `fields` allow-lists (`html_url` rejected by list)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
github/github-mcp-server#3960 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
JuliusBrussee/caveman#1594 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
C-bug O-community X-blathers-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
cockroachdb/cockroach#176264 · 1 bình luận ·
-
security trivy
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
kubefleet-dev/kubefleet#1068 ·
Maintainer thường phản hồi trong vòng 3 ngày