Repository navigation
Conversation
Reviewer's GuideThe PR fixes outdated WhatsApp Web handshakes by applying the resolved client version through Sequence diagram for WhatsApp client version selection and handshakesequenceDiagram
participant StartClient
participant WhatsAppWeb
participant Store
participant WhatsAppServer
StartClient->>StartClient: fetchWhatsAppWebVersion()
alt configured version
StartClient->>Store: SetWAVersion(configured version)
else fetched version
StartClient->>WhatsAppWeb: GET /sw.js with User-Agent
WhatsAppWeb-->>StartClient: active web version
StartClient->>Store: SetWAVersion(web version)
else fetch fails or version is incomplete
StartClient->>Store: SetWAVersion(2.3000.1052812464)
end
Store-->>Store: BaseClientPayload.UserAgent.AppVersion updated
StartClient->>WhatsAppServer: WebSocket handshake
WhatsAppServer-->>StartClient: handshake accepted with current client version
Flow diagram for WhatsApp Web version resolutionflowchart TD
A[StartClient] --> B{Configured version available?}
B -- Yes --> E[Select configured version]
B -- No --> C["fetchWhatsAppWebVersion()"]
C --> D{Fetch succeeds?}
D -- Yes --> F[Select web version]
D -- No --> G[Select fallback 2.3000.1052812464]
E --> H[Set DeviceProps.Version]
F --> H
G --> H
H --> I[store.SetWAVersion]
I --> J[Update BaseClientPayload.UserAgent.AppVersion]
J --> K[WebSocket handshake]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pkg/whatsmeow/service/version_test.go" line_range="11" />
<code_context>
+
+func TestSetWAVersionUpdatesBaseClientPayload(t *testing.T) {
+ testVersion := store.WAVersionContainer{2, 3000, 1052812464}
+ store.SetWAVersion(testVersion)
+
+ gotVersion := store.GetWAVersion()
</code_context>
<issue_to_address>
**Handshake integration goes untested**
When startClient omits its SetWAVersion call or passes a version other than the one resolved for the client, `TestSetWAVersionUpdatesBaseClientPayload` calls `store.SetWAVersion(testVersion)` at line 11 itself, so it still passes if `StartClient` omits the changed call or supplies the wrong resolved version; the handshake can remain outdated.
Exercise the StartClient version-setting path with a controlled resolved version and assert the resulting handshake payload.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: pkg/whatsmeow/service/version_test.go:11
|
|
||
| func TestSetWAVersionUpdatesBaseClientPayload(t *testing.T) { | ||
| testVersion := store.WAVersionContainer{2, 3000, 1052812464} | ||
| store.SetWAVersion(testVersion) |
There was a problem hiding this comment.
🟡 Medium · Handshake integration goes untested
When startClient omits its SetWAVersion call or passes a version other than the one resolved for the client, TestSetWAVersionUpdatesBaseClientPayload calls store.SetWAVersion(testVersion) at line 11 itself, so it still passes if StartClient omits the changed call or supplies the wrong resolved version; the handshake can remain outdated.
Exercise the StartClient version-setting path with a controlled resolved version and assert the resulting handshake payload.
Prompt for AI agents
In `pkg/whatsmeow/service/version_test.go` at line 11:
**Handshake integration goes untested**
When startClient omits its SetWAVersion call or passes a version other than the one resolved for the client, `TestSetWAVersionUpdatesBaseClientPayload` calls `store.SetWAVersion(testVersion)` at line 11 itself, so it still passes if `StartClient` omits the changed call or supplies the wrong resolved version; the handshake can remain outdated.
Exercise the StartClient version-setting path with a controlled resolved version and assert the resulting handshake payload.…outdated 405) Desde 02/11/2026 o WhatsApp recusa a versao 2.3000.1042386815, fixa no whatsmeow, com "Client outdated (405)": nenhuma instancia conecta nem pareia, e o /instance/pair falha com "websocket disconnected before info query returned response". O StartClient ja buscava a versao atual em web.whatsapp.com/sw.js (ou lia WHATSAPP_VERSION_*), mas so gravava em store.DeviceProps.Version, que vai no cadastro do aparelho. A versao do handshake e a de store.SetWAVersion, que nunca era chamada. - resolveWAVersion escolhe: configurada > WhatsApp Web > reserva (2.3000.1052682108, lida em 02/11), so se mais nova que a do whatsmeow. - applyWAVersion chama store.SetWAVersion e grava o DeviceProps, sob mutex porque a versao e global e varias instancias sobem juntas. - A busca da versao ganha timeout de 10 s; sem ele, um WhatsApp Web lento travava o StartClient. Mesma correcao dos PRs evolution-foundation#227 e evolution-foundation#229 do upstream, ainda abertos. Testado em producao na imagem hub.cliiz.net/evogo:1.1.1-pg.
Description
Fixes recurrent WhatsApp connection drops and handshake failures caused by
Client outdated (405) connect failure (client version: 2.3000.1042386815).Root Cause
Although
fetchWhatsAppWebVersion()successfully fetches the active WhatsApp Web revision fromhttps://web.whatsapp.com/sw.js(e.g.,2.3000.1052712929), the code was previously only settingstore.DeviceProps.Version.In
whatsmeow, the actual WebSocket connection handshake payload usesstore.BaseClientPayload.UserAgent.AppVersion, which is only updated whenstore.SetWAVersion(...)is called. Becausestore.SetWAVersionwas never invoked,whatsmeowalways presented its static library default version (2.3000.1042386815) during the handshake. When WhatsApp servers deprecate that specific revision, they reject the WebSocket handshake with HTTP 405 Outdated, causing reconnection loops and EOF drops.Changes
store.SetWAVersion(store.WAVersionContainer{...})inStartClientso the resolved web version or configured version actually updatesBaseClientPayload.UserAgent.AppVersion.2.3000.1052812464) in case the dynamic web fetch fails, preventing the client from falling back to the deprecated1042386815.User-Agentand a 10s timeout tofetchWhatsAppWebVersion()to avoid hanging or Cloudflare edge blocks.version_test.goverifying thatstore.SetWAVersionupdatesstore.BaseClientPayload.UserAgent.AppVersion.Related Issue
Fixes 405 Client Outdated connect failures on WhatsApp Web handshake.
Type of Change
Testing
Tested with unit test
TestSetWAVersionUpdatesBaseClientPayloadand verified thatBaseClientPayload.UserAgent.AppVersionis successfully updated to match the active WhatsApp Web client revision.Screenshots (if applicable)
N/A
Checklist
Additional Notes
None.
Summary by Sourcery
Update the WhatsApp client version handling to keep handshake metadata current and prevent recurring connection drops caused by deprecated client revisions.
Bug Fixes:
Tests: