fix(feishu): retry sends with a fresh tenant token#401
Open
xukp20 wants to merge 1 commit intochenhg5:mainfrom
Open
fix(feishu): retry sends with a fresh tenant token#401xukp20 wants to merge 1 commit intochenhg5:mainfrom
xukp20 wants to merge 1 commit intochenhg5:mainfrom
Conversation
chenhg5
approved these changes
Apr 1, 2026
Owner
chenhg5
left a comment
There was a problem hiding this comment.
LGTM. Robust fix for Feishu tenant token issues.
Review summary:
- ✅ Targeted recovery for stale token errors
- ✅ Fresh token fetch + cache-disabled client replay
- ✅ Comprehensive test coverage
- ✅ CI passes
- ✅ Fixes #395 (partial)
Good resilience improvement for Feishu sends.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix Feishu/Lark outgoing replies failing with
99991663 Invalid access tokenafter long uptime.Partially addresses #395.
What changed
99991663/Invalid access token)Why
The current Lark SDK does retry once on
99991663, but in practice that is not always enough.The root cause is that tenant token cache remains enabled, and on retry the SDK can still reuse the same stale cached token. In addition, request-level tenant token override is not sufficient when token cache is enabled.
So cc-connect now adds a narrow recovery layer on top of the SDK:
This keeps the fix small and targeted while making outgoing Feishu sends much more resilient.
Scope
This PR only fixes the Feishu/Lark outgoing message failure caused by stale tenant access tokens.
It does not attempt to address the other symptoms mentioned in #395, such as Telegram polling conflicts or unexpected restarts, which may have different root causes.
Validation
pnpm install --frozen-lockfile && pnpm buildinweb/go build ./...go test ./... -v -racego test ./... -coverprofile=coverage.out -covermode=atomic$(go env GOPATH)/bin/actionlint -colorgo test -v -tags=smoke,no_web ./tests/e2e/...go test -v -tags=regression,no_web ./tests/e2e/...go test -bench=. -benchmem -tags=performance,no_web ./tests/performance/...