Conversation
When contextToken is absent the backend returns 200 but silently drops the message, so callers believe delivery succeeded (a false success). Explicitly throw on missing contextToken so the caller's try/catch can report a typed delivery failure instead of a silent drop. See P1-6 / openclaw issue: external Weixin channel outbound silent-success. Limitations: stale (present-but-expired) tokens are still accepted by the backend and silently dropped; refreshing token freshness is a separate fix.
8 tasks
|
感谢你定位缺少 如果你愿意,欢迎由你基于社区仓库当前 https://github.com/NewFuture/openclaw-weixin 迁移时请按当前错误传播和事件上报路径处理:5 个入口都应在调用后端前明确失败,并分别增加回归测试;同时需要一个携带有效 token 的反例,证明正常发送不受影响。日志和错误信息请不要包含原始 token、完整目标 ID 等敏感值。这样可以让 channel、普通回复和媒体发送都得到真实的失败结果,而不是继续上报假成功。 贡献指南: 说明: |
…t-drop) Adapted from Tencent#247 (authored by stwhwing). Community edition (NewFuture/openclaw-weixin) still had 5 send entry points that warned-then-sent without contextToken, causing iLink to return HTTP 200 with empty body and silently drop the message while the caller saw a fake success. Changes: - send.ts: throw on missing contextToken in all 5 send entry points (sendMessageWeixin, sendMessageItemWeixin, sendImageMessageWeixin, sendVideoMessageWeixin, sendFileMessageWeixin); error messages carry no raw token or full recipient id (redacted via redactToken). - send.test.ts: flip 4 existing 'no throw' tests to assert throw + backend not called; add focused regression + valid-token counterexample. - CHANGELOG: add Unreleased entry (zh + en); no version bump. Verified: send.test.ts 23/23, tsc clean, biome 0 errors.
stwhwing
added a commit
to stwhwing/openclaw-weixin-nf
that referenced
this pull request
Aug 10, 2026
…t-drop) Adapted from Tencent/openclaw-weixin#247 (authored by stwhwing). Community edition (NewFuture/openclaw-weixin) still had 5 send entry points that warned-then-sent without contextToken, causing iLink to return HTTP 200 with empty body and silently drop the message while the caller saw a fake success. Changes: - send.ts: throw on missing contextToken in all 5 send entry points (sendMessageWeixin, sendMessageItemWeixin, sendImageMessageWeixin, sendVideoMessageWeixin, sendFileMessageWeixin); error messages carry no raw token or full recipient id (redacted via redactToken). - send.test.ts: flip 4 existing 'no throw' tests to assert throw + backend not called; add focused regression + valid-token counterexample. - CHANGELOG: add Unreleased entry (zh + en); no version bump. Verified: send.test.ts 23/23, tsc clean, biome 0 errors.
NewFuture
added a commit
to NewFuture/openclaw-weixin
that referenced
this pull request
Aug 10, 2026
…t-drop) (#60) * fix(weixin): refuse to send when contextToken is missing (avoid silent-drop) Adapted from Tencent/openclaw-weixin#247 (authored by stwhwing). Community edition (NewFuture/openclaw-weixin) still had 5 send entry points that warned-then-sent without contextToken, causing iLink to return HTTP 200 with empty body and silently drop the message while the caller saw a fake success. Changes: - send.ts: throw on missing contextToken in all 5 send entry points (sendMessageWeixin, sendMessageItemWeixin, sendImageMessageWeixin, sendVideoMessageWeixin, sendFileMessageWeixin); error messages carry no raw token or full recipient id (redacted via redactToken). - send.test.ts: flip 4 existing 'no throw' tests to assert throw + backend not called; add focused regression + valid-token counterexample. - CHANGELOG: add Unreleased entry (zh + en); no version bump. Verified: send.test.ts 23/23, tsc clean, biome 0 errors. * fix(weixin): align missing-token callers Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: New Future <6290356+NewFuture@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
fix(weixin): refuse to send when contextToken is missing instead of silent-drop
Summary
sendMessageWeixin/sendMessageItemWeixin/sendImageMessageWeixin/sendVideoMessageWeixin/sendFileMessageWeixincurrently onlylogger.warnwhen
opts.contextTokenis missing, then send the request anyway. The WeChatiLink backend silently discards messages sent without a (fresh) context
token — it returns HTTP 200 with no body and the message never reaches the
user. The function then returns a self-generated
clientIdasmessageId,so every caller up the stack (channel
sendText/sendMedia,emitWeixinMessageSent)reports success while nothing was delivered. This is a silent-failure bug.
This PR changes the 5
contextToken missingsites to throw a typed errorinstead of warning-and-sending. Callers already wrap these in
try/catchandreport delivery failure, so the throw is handled correctly.
Root cause
src/messaging/send.ts:if (!opts.contextToken) { logger.warn(...); }then
await sendMessageApi(...)is still called.sendMessageApionly rejects on transport/HTTP errors; a 200-with-empty-body"silent drop" is treated as success.
{ messageId: clientId }whereclientIdis locallygenerated, not an acknowledgement from the server.
Changes
In all 5 send functions, replace:
with:
(
<fn>is the respective function name.)Testing
contextToken missingbranches are the only silent-drop pathsin
src/messaging/send.ts.git apply --checkpasses cleanly on the published2.4.6source(
packages/openclaw-weixin/src/messaging/send.ts).channel.tssendText/sendMedia) alreadytry/catchand callemitWeixinMessageSent(success: false)on throw, so behaviour is correct.Limitations / follow-up
contextTokencase. It does not cover atoken that is present but stale (not refreshed by a recent inbound
message) — the backend still silently drops those. A more complete fix would
also refuse/retry when the cached token age exceeds a threshold (e.g. read
from the token store). Happy to follow up if maintainers want that scope.
which is unaffected by the iLink token lifecycle.
Reproduction & patch regeneration
How to reproduce the bug
contextTokenis missing orstale — i.e. a bot that has not received a recent inbound message from
that user. The iLink backend only issues a fresh token per inbound message,
so a quiet bot accumulates a missing/stale token.
openclaw message send, a cron job withdeliver: weixin, or an@botreply through the weixin channel.emitWeixinMessageSent(success: true)fires, yetthe recipient receives nothing. The backend returned HTTP 200 with an
empty body and silently dropped the message. That is the silent-failure bug.
How to regenerate this patch for a new version
The fix is mechanical (5 identical
warn→throwsites), so a helper scriptis provided for regression testing against future releases:
gen_patch.pyrewrites the 5contextToken missingbranches and emits aunified diff with LF line endings (so it applies cleanly on Linux/macOS).
It is a regeneration/regression helper only — not the reproduction steps
above. The script accepts the path to
send.tsas its only argument; if itreports a count other than 5, the source version has drifted and the patch
needs a manual review.
Verify before opening the PR
Checklist
git apply --checkpasses on2.4.6