Skip to content

fix(whatsapp-gateway): IQ probe passes single JID, not a list - #118

Closed
retog wants to merge 1 commit into
mainfrom
fix/whatsapp-iq-probe-jid-arg
Closed

fix(whatsapp-gateway): IQ probe passes single JID, not a list#118
retog wants to merge 1 commit into
mainfrom
fix/whatsapp-iq-probe-jid-arg

Conversation

@retog

@retog retog commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Problem

After the #115 health-wedge fix + instance update, /health reports the WhatsApp bridge as not connected with:

bridge link is up but info queries (usync) are failing … expected JID got list

That message is not a real usync timeout — it is a type error in the probe itself. The IQ probe calls the device-lookup with a list:

fn([own_jid])   # get_user_info / get_user_devices

The installed neonize build wants a single JID and rejects the list. So the probe raises every cycle, and the loop cannot distinguish that TypeError from a genuine wedge. Two consequences:

  1. False negative healthiq_ok=False / connected=false even when the bridge can send. This is why the /gateways page and /health disagree.
  2. Self-inflicted churn — on each "wedge" the loop tears the connection down to force a reconnect (_maybe_iq_reconnect). A bridge reconnected on every probe interval also fails real sends' own usync device resolution — the "usync timed out" failures seen when sending to a first-contact recipient.

Fix

Pass a single JID, falling back to the list form on TypeError, mirroring the existing build_jid() version adapter — robust across neonize argument-shape changes.

Verifies

  • ast.parse clean.
  • Diagnosed live: /health error string matches line 970 exactly; send path (_to_jidbuild_jidsend_message) is correct and unaffected.

Follow-up to #115. 🤖 Generated with Claude Code

The IQ probe added for the health-wedge detection (#115) calls
get_user_info/get_user_devices with a list argument (fn([own_jid])).
The installed neonize build rejects that with a type error
("expected JID got list"), which is raised on every probe cycle.

The probe loop cannot tell that TypeError apart from a real wedge, so
it (a) forces iq_ok=False and reports the bridge as disconnected even
when it can send, and (b) tears the connection down to force a
reconnect on every cycle — churning an otherwise-healthy bridge and
breaking real sends' own device-list (usync) resolution.

Try the single-JID form first and fall back to the list form on
TypeError, mirroring the build_jid() version adapter, so the probe
works across neonize argument-shape changes.

Co-Authored-By: Claude <noreply@anthropic.com>
@aros-agent

Copy link
Copy Markdown
Contributor

Written by Aros, the project's AI agent, from my own account @aros-agent.

This looks fully superseded by #119 (merged 2026-08-16T19:19:20Z), and safe to close. Verified from the content of main's scripts/whatsapp-gateway.py rather than from either PR's badges:

  • _iq_probe_once on main already tries the scalar shape first and falls back to the list form — the entirety of this PR's change — via the (method, style) candidate loop.
  • It goes further than this diff in two ways that matter for the exact failure quoted in this PR's body: shape errors are classified by _is_call_shape_error, which matches TypeError or the protobuf message ("parameter to initialize message field"), so the classification doesn't depend on which exception class the installed protobuf raises — this diff's bare except TypeError would miss the message-only case; and the first working (method, shape) is cached in _iq_call, so a later exception is never re-classified as a shape issue and a genuine usync timeout still raises.
  • The CONFLICTING state here is fix(whatsapp): correct IQ-probe call shape; show pairing QR only when re-pairing helps #119 rewriting the same lines (the fn([own_jid]) call at old line 970 no longer exists on main).

Nothing in this diff is absent from main, so closing loses nothing. Closing is yours to do — it's your PR.

@retog

retog commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

Covered by 119

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.

2 participants