Repository navigation
Conversation
Delivery targets reach the plugin as `chat:<chat_id>`, `user:<open_id>`, or sometimes as a bare Feishu id. Cron runs redelivered after a restart pass the raw chat id with no prefix, which the resolver treated as an open_id and Feishu rejected with `99992361 open_id cross app`. Treat the id prefix as authoritative (oc_ -> chat, ou_ -> user), keep the explicit prefixes working, and cover the mapping with tests.
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.
Problem
The outbound delivery path only understood two shapes of delivery target:
chat:<chat_id>anduser:<open_id>. Anything else was treated as anopen_id.Some delivery paths hand the plugin a bare Feishu id with no prefix. Cron runs redelivered after a restart are one of them: the run's
deliveryContext.toreaches the plugin asoc_444a075683cff5b4bbcd49fa869afc87, with nochat:prefix.resolveReceiverthen produced{ receiveIdType: "open_id", receiveId: "oc_..." }and Feishu rejected every attempt:Observed on Cola 1.4.5 / plugin 0.2.1: one stuck daily-report run retried after every restart and produced 369 failed sends in a single month — always the same target, always the same error code, never a content problem (replaying the identical text through
im/v1/messageswithreceive_id_type=chat_idsucceeds).Change
resolveReceivernow normalizes the target first, and the id prefix is authoritative:oc_...chat_id(new — this is the bug)chat:oc_...chat_idou_.../user:ou_...open_id, upgraded to the DMchat_idwhen the chat map knows ituser:oc_...(mismatched prefix)chat_id— a chat id is never a valid open_id""/"chat:"normalizeDeliveryTargetis a new exported pure helper so the mapping can be tested on its own. Well-formedchat:/user:targets behave exactly as before;sendMediashares the same resolver, so it is fixed too.Tests
plugins/feishu/tests/outbound-send.test.tscovers the bare-chat-id regression, bare open ids, explicit prefixes, a mismatched prefix, empty targets, and DM-map hits/misses.Gates run locally on this branch (all green):
pnpm fmt:check(114 files),pnpm lint,pnpm test— 162 tests in 21 files, including the 9 new ones,pnpm build:registry, plustypecheckandbuildforplugins/feishu.cola-plugin-feishubumped to 0.2.2.Fixes the retry storm described above; after deploying, a redelivered run that previously burned a failed send per attempt delivers normally.