OpenWA icon indicating copy to clipboard operation
OpenWA copied to clipboard

[Bug]: Some payloads in Swagger give errors when testing.

Open onepay-ye opened this issue 4 months ago • 1 comments

Pre-flight

  • [x] I searched existing issues and this isn't a duplicate
  • [x] I'm on the latest released version (or noted my version below)

OpenWA version

0.13.1

Deployment

Docker Compose

Database

SQLite (default)

WhatsApp engine

whatsapp-web.js

What happened?

Hello, I encountered some errors while building using the Swagger API:

As per the attached request, this doesn't work at all and gives an error. The reason is the presence of the value:

"mentions": [
"[email protected]"
]

I removed it, and then the interface worked without any errors.

{
  "chatId": "[email protected]",
  "text": "Hello from OpenWA!",
  "mentions": [
    "[email protected]"
  ]
}

These values ​​are either outdated, inactive, or haven't been updated by you.

After updating from version 0.10.1 to the current versions, I made some additions, including changing the connection source via the Swagger API.

As shown in the attached image, you should have added an option to add the connection server because now I'm getting the message: Failed to fetch.

Possible Reasons:

CORS Network Failure URL scheme must be "http" or "https" for CORS request.

This error appears even when I'm in production mode.

Image

Steps to reproduce

1- Payload like this is work fine

{
  "chatId": "[email protected]",
  "text": "Hello from OpenWA!"
}

Expected behavior

No response

Relevant logs


Environment / additional context

No response

onepay-ye avatar Aug 04 '26 20:08 onepay-ye

Thanks for reporting this — both halves turned out to be real, and both are fixed in v0.14.1.

The Swagger "Failed to fetch"

You were right that this appeared after upgrading, and right that the server was the problem. The spec declared a single server, http://{host}:{port}, whose defaults resolve to http://localhost:2785. Swagger UI aims "Try it out" at that first server rather than at the address you loaded the docs from — so on any other host or port it called your own machine. 0.10.1 declared no server at all, which is why it worked for you before.

The docs now list a relative server first, so Try-it targets whatever origin served the page. The {host}/{port} entry is still in the Servers dropdown if you want to point the docs at a different instance.

If you are on an older build, the workaround is that same dropdown: set host and port to the address you opened the docs on.

The payload with mentions

Here the cause was somewhere other than where it looked, and it is worth being precise because two separate bugs were involved.

mentions itself was fine. What failed was the chatId in the example — 628123456789 is a placeholder that is not a WhatsApp account, and whatsapp-web.js cannot resolve it. That produced a bare No LID for user from inside WhatsApp Web, which the gateway passed straight through as 500 Internal server error — no message, nothing to act on. Tested against a live session, a text send with mentions to a real number returns 201 normally.

Three fixes went in:

  • Sending to a number WhatsApp cannot resolve now answers 400 naming the recipient, instead of an empty 500. It says either the number is not on WhatsApp, or the session has no existing chat with it — the gateway genuinely cannot tell those apart, and the second case is an upstream whatsapp-web.js limitation.
  • A malformed mentions entry (a bare number, anything without a proper suffix) is now rejected with a 400 naming the field. Previously it reached WhatsApp Web's id parser and threw from minified code, so the log line was literally t: t.
  • The Try-it body itself was broken in a way you would have hit next: since 0.14.0 it also carried linkPreview: false together with a customLinkPreview, a combination the endpoint rejects, so every Execute returned 400 regardless of what you typed. Swagger UI builds that body from every field in the schema, not just the required ones. All the send routes now ship explicit examples — the media routes had the same problem, where the sampled body sent the literal string "string" instead of the example URL.

One note on the example

mentions is documented for group chats, and needs the @<number> token present in the text as well:

{ "chatId": "[email protected]", "text": "Hello @62811", "mentions": ["[email protected]"] }

That is now one of the two examples offered in the dropdown above the request body, alongside a plain text send.

Small correction on the version: there is no 0.10.1→0.13.1 — 0.13.0 was the release before this one. Nothing turns on it, just so the numbers line up if you compare.

Upgrade to v0.14.1 and both should be sorted. Please reopen if anything still misbehaves.

rmyndharis avatar Aug 05 '26 15:08 rmyndharis