fix(api): make sendMessage failures actionable on empty errmsg - #8
Merged
Merged
Conversation
When `sendMessage` fails with a non-zero `ret` the server often returns an empty `errmsg` (commonly `ret=-2`), so the thrown error was `sendMessage ret=-2 errmsg=(none)` — impossible to act on. The most common cause on agent-initiated outbound delivery (cron reminders, scheduled digests) is an expired or missing `context_token`: it is only refreshed by a recent inbound message from the recipient, so after a long idle period the bot cannot send until the user messages it again. Add `describeSendMessageFailure`, which passes through a real server errmsg but, when it is empty, reports the likely cause and whether a `context_token` was included in the request. No behavior change on success or when the server provides an error detail. Refreshing the token automatically is not possible from the bot side (it depends on inbound user activity), so this focuses on diagnosability. Fixes #225
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.
Upstream source
Exact mirror of Tencent/openclaw-weixin#230 by @draix.
draix/openclaw-weixin:fix/sendmessage-actionable-errorcef0bfc390393f716903e16d50408118047f87e0da9efec952286a63df432808ceb6323fd67fc7514feec89ff2b40c93578a96f6325bdd536ad9d38eUpstream intent
Make
sendMessagefailures actionable when the backend returns a nonzeroretwith an emptyerrmsg.Local review status
This exact mirror merges cleanly into the current target and its API tests, typecheck, and build pass, but it remains a Draft until these findings are addressed:
context_tokenpresence, although the same return code can represent rate limits, media failures, or unrelated backend errors;errmsgreaches.trim()and throws aTypeError, masking the usefulretvalue.The follow-up should preserve
ret, type-guard backend fields, and provide neutral guidance when the cause is ambiguous. Original discussion remains on the upstream PR.