Skip to content

WeChat send silently succeeds when iLink returns non-zero ret with errcode=0 #210

Description

@louiseboo

Summary

The WeChat adapter treats a send as successful when the iLink sendmessage endpoint returns a non-zero ret while errcode is zero. This can produce a false-positive delivery receipt even though the message was not delivered.

Version

  • Reproduced against Raven 0.1.4 installed package
  • Confirmed the same logic in the v0.1.9 tag and current main

Minimal reproduction

import asyncio
from raven.channels.adapters.weixin.channel import WeixinChannel

async def main():
    ch = object.__new__(WeixinChannel)

    async def fake_post(endpoint, body=None, *, auth=True):
        return {"ret": -2, "errcode": 0, "errmsg": "prepare failed"}

    ch._post = fake_post
    await ch._send_text("sanitized-user", "test", "sanitized-context")
    print("false success")

asyncio.run(main())

Actual result: _send_text() returns normally and the caller can report success.

Observed real response, sanitized:

{"ret": -2, "errcode": 0, "errmsg": "prepare failed"}

Expected behavior

_send_text() should raise when either ret or errcode is non-zero, consistent with _poll_once(). The exception should preserve ret, errcode, and the server message so automation callers cannot claim delivery.

Actual behavior

The implementation only checks errcode:

if errcode := data.get("errcode", 0):
    raise RuntimeError(...)

A non-zero ret with errcode=0 is silently ignored.

Impact

  • Automated jobs can report successful WeChat delivery when the server rejected message preparation.
  • Operators may miss time-sensitive notifications.
  • Delivery audits become misleading.

Suggested fix

Validate both fields and add regression tests for non-zero ret, non-zero errcode, and the success case.

Privacy

All user identifiers, tokens, local paths, and message contents have been removed from this report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions