Skip to content

fix(provider-baileys): honor the manual WA version and recover from 405 - #1296

Merged
leifermendez merged 2 commits into
builderbotfrom
fix/baileys-wa-version-resolution
Nov 18, 2026
Merged

leifermendez merged 2 commits into
builderbotfrom
fix/baileys-wa-version-resolution

Conversation

@leifermendez

Copy link
Copy Markdown
Member

Summary

Bots created from the baileys starters failed with 405 Connection Failure. The starter template passed
{ version: [2, 3000, 1035824857] }, and ...this.globalVendorArgs was spread after the resolved version,
so that stale value reached the socket. baileys.log still printed "Using live WA Web version", which hid the
cause.

Tested against WhatsApp today with a fresh auth state per run:

Version Result
[2, 3000, 1035824857] (old template) 405, 3 of 3 runs
[2, 3000, 1043857760] (Baileys recommended / bundled) QR issued
[2, 3000, 1055185710] (live WhatsApp Web) QR issued

Changes

@builderbot/provider-baileys

  • New src/waVersion.ts resolves the version in this order: manual (WA_VERSION env, then the version option),
    then the Baileys-recommended version, then live WhatsApp Web, then the bundled one. Each lookup has a 5 s timeout.
    Baileys lookups never throw (they return the bundled version with error set), so the old try/catch chain never
    reached its fallbacks; the error field now drives them.
  • version accepts the text copied from https://wppconnect.io/whatsapp-versions/ ('2.3000.1054953954-alpha').
  • The resolved version is set after the spread, so the raw option can no longer bypass resolution.
  • On a 405 the provider reconnects with the live WhatsApp Web version, skipping the manual one, up to 3 times. After
    that it emits auth_failure explaining the manual fix.
  • baileys.log records the source: Using WA Web version 2.3000.x (source: baileys).
  • README section "WhatsApp Web version".

Starters (generated with pnpm run generate.templates)

  • The 12 baileys starters call createProvider(Provider). The comment keeps the manual fix (wppconnect version or
    WA_VERSION).

Test plan

  • provider-baileys: 279 tests pass, including new waVersion.test.ts and 405 / manual-version cases in
    lifecycle.test.ts
  • pnpm test across the monorepo (pre-push)
  • pnpm --filter @builderbot/provider-baileys build
  • CI Templates in sync (not run locally: on Windows it rewrites every starter with LF/CRLF noise)

Follow-up

provider-sherpa has the same problem: its template version (1034028152) and its fallback (1023223821) both get
405 today. That goes in a separate PR.

leifermendez and others added 2 commits November 18, 2026 18:32
The `version` option was spread after the resolved version, so a stale value
from the starter template reached the socket and WhatsApp rejected it (405)
while the log claimed the live version was in use.

- Resolve the version manual (WA_VERSION, then `version`) -> Baileys-recommended
  -> live WhatsApp Web -> bundled, each lookup bounded by a 5 s timeout. Baileys
  lookups never throw, so their `error` field now drives the fallback.
- Accept the version as copied from wppconnect.io ('2.3000.x-alpha').
- On 405, reconnect with the live WhatsApp Web version (up to 3 times), then
  emit auth_failure explaining the manual fix.
- Log the version source in baileys.log.

Co-authored-by: Cursor <cursoragent@cursor.com>
[2, 3000, 1035824857] is rejected by WhatsApp with 405. The version is now
resolved automatically; the comment keeps the manual fix (wppconnect.io
version or WA_VERSION) for emergencies.

Co-authored-by: Cursor <cursoragent@cursor.com>
@leifermendez
leifermendez merged commit 524ec4a into builderbot Nov 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant