Skip to content

fix(weixin): recover from ret=-2 with empty stale-context errors - #73908

Closed
notwin wants to merge 1 commit into
NousResearch:mainfrom
notwin:fix/weixin-stale-context-empty-errmsg
Closed

notwin wants to merge 1 commit into
NousResearch:mainfrom
notwin:fix/weixin-stale-context-empty-errmsg

Conversation

@notwin

@notwin notwin commented Jul 29, 2026

Copy link
Copy Markdown

Summary

  • Treat ret=-2 / errcode=-2 with an empty errmsg as the stale-context variant already recognized for "unknown error".
  • Remove the stale peer token from both memory and the disk-backed token store before the existing tokenless retry.
  • Add regression coverage for helper classification, durable token deletion, and the full send retry path.

Why

Cron-initiated pushes to inactive Weixin DMs can return ret=-2, errcode=None, errmsg=None when the persisted context_token has gone stale. The current adapter misclassifies that response as a rate limit, opens the circuit breaker, and drops the push. A new inbound message refreshes the token and makes later sends work again.

This extends the existing stale-session fallback without changing explicit frequency/rate-limit handling.

Fixes #18100.

Tests

  • pytest tests/gateway/test_weixin.py tests/cron/test_scheduler.py -q -o addopts= — 321 passed
  • ruff check gateway/platforms/weixin.py tests/gateway/test_weixin.py
  • git diff origin/main...HEAD --check

@notwin

notwin commented Jul 29, 2026

Copy link
Copy Markdown
Author

Closing this approach. We will not pursue a source-level change here.

@notwin notwin closed this Jul 29, 2026
@notwin
notwin deleted the fix/weixin-stale-context-empty-errmsg branch July 29, 2026 05:55
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/wecom WeCom / WeChat Work adapter P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 29, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Duplicate of #35714: the earlier open fix is the canonical Weixin stale context_token recovery path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

weixin: ret=-2 with empty errmsg also indicates stale context_token (follow-up to #17228)

2 participants