Skip to content

send_message() raises DecodeError parsing SendMessageReturnFunction ("Wire format was corrupt") even though the message is delivered #199

Description

@michelhabib

Describe the bug

Every call to send_message() raises a google.protobuf.message.DecodeError while parsing the send return (SendMessageReturnFunction), even though the message is actually delivered to the recipient. So the send succeeds on the Go/whatsmeow side, but the Python-side parse of the return value fails.

Receiving messages works perfectly — only the SendMessageReturnFunction return type fails to parse.

Environment

  • neonize: 0.4.1.post0 (installed from the prebuilt wheel via pip install neonize)
  • protobuf: 7.35.1
  • Python: 3.12
  • OS: Windows 11 (x86_64)

Minimal reproduction

Pure neonize, no other code. Requires an already-paired session.db:

import asyncio
from neonize.aioze.client import NewAClient
from neonize.utils import build_jid

client = NewAClient(r"session.db")  # already paired

async def main():
    await client.connect()
    await asyncio.sleep(6)  # let the paired session establish
    to = build_jid("15551234567", "s.whatsapp.net")  # a real recipient
    resp = await client.send_message(to, "hello")     # <-- raises DecodeError
    print("SEND_OK", type(resp).__name__)
    await client.disconnect()

asyncio.run(main())

Traceback

File ".../neonize/aioze/client.py", line 688, in send_message
    model = SendMessageReturnFunction.FromString(protobytes)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
google.protobuf.message.DecodeError: Error parsing message with type
'neonize.SendMessageReturnFunction': Wire format was corrupt

The failing line is where the raw bytes returned by the Go SendMessage call are parsed:

bytes_ptr = await self.__client.SendMessage(...)
protobytes = bytes_ptr.contents.get_bytes()
free_bytes(bytes_ptr)
model = SendMessageReturnFunction.FromString(protobytes)  # <-- raises here

Expected behavior

send_message() returns a SendResponse.

Actual behavior

send_message() raises DecodeError while parsing SendMessageReturnFunction. The message is still delivered to the recipient (confirmed by the recipient receiving it) — only the return value cannot be parsed.

What I've already investigated / ruled out

  • Not caller code — reproduced with pure neonize (NewAClient + connect + send_message), nothing else involved.
  • Message is delivered — the recipient receives the message every time; only the parse of the return fails.
  • Inbound parsing is fineMessageEv (incoming messages) parse correctly, so the shared library and protobuf runtime work in general; only SendMessageReturnFunction fails.
  • Not a protobuf runtime version mismatch — fails identically on protobuf 7.35.1 and 7.34.1 (7.34.1 exactly matches the gencode version stamped in the generated files). Downgrading to protobuf 6.x is not possible: the generated code requires runtime ≥ 7.34.1 (VersionError: gencode 7.34.1 runtime 6.33.6), and this is also the case on 0.3.18.post0.

Questions

  1. Is this a known issue with 0.4.1.post0?
  2. Is there a version known to send_message() correctly (returning a valid SendResponse)?
  3. Could the bundled Go shared library be serializing SendMessageReturnFunction from a different schema revision than the Python *_pb2 gencode expects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions