Summary
After a successful QR pairing, GET /session/status returns "jid": "" even though connected: true and loggedIn: true, and even though the users.jid column in the database holds the correct JID. The JID is written to the DB on PairSuccess, but the in-memory userinfo cache that /session/status reads from is not refreshed, so the endpoint keeps returning an empty jid until the process is restarted (on restart the cache is loaded from the DB and the value appears again).
This breaks integrations that rely on /session/status.jid to learn the connected phone number right after pairing.
Environment
- wuzapi commit:
70642149a0e8a81d49caa640f557217e03e09729 (branch main)
- whatsmeow:
v0.0.0-20260721154117-8b4a8ba0d318 (latest at build time)
- Build:
CGO_ENABLED=0, GOOS=linux, DB backend: PostgreSQL
- Go: 1.25.x
Steps to reproduce
- Create a user via the admin API and connect it (
/session/connect).
- Scan the QR code with a phone to pair.
PairSuccess fires and is logged with the correct JID.
- Immediately call
GET /session/status with the user token.
Expected
/session/status returns the paired JID:
{ "connected": true, "loggedIn": true, "jid": "7989XXXXXXX:65@s.whatsapp.net", ... }
Actual
jid is empty although the session is logged in:
{ "connected": true, "loggedIn": true, "jid": "", ... }
Evidence
Logs at pairing time — JID is correctly computed and written to the DB:
INFO QR Pair Success ID=7989XXXXXXX:65@s.whatsapp.net Platform=android token=<token> userid=<userid>
DEBUG User info updated field=Jid value=7989XXXXXXX:65@s.whatsapp.net
INFO User information set jid=7989XXXXXXX:65@s.whatsapp.net token=<token> userid=<userid>
A couple of seconds later, /session/status reads from the cache and gets nothing:
INFO User info name from Cache name=
INFO User info values ... Jid= Name=<user> ...
INF Got API Request url=/session/status status=200 ...
Database confirms the JID is stored (so it is purely a read/cache issue, not a write issue):
SELECT id, jid, name, connected FROM users;
-- <userid> | 7989XXXXXXX:65@s.whatsapp.net | <user> | 1
Notes / likely cause
It looks like PairSuccess persists the JID to the DB but does not update the cached userinfo entry that the /session/status handler reads (userInfo.Get("Jid")). A process restart repopulates the cache from the DB, which is why the value reappears only after a restart.
Possible fixes:
- Refresh/invalidate the userinfo cache entry when the JID is updated (on
PairSuccess/Connected), or
- Have
/session/status read the JID from the DB (or fall back to the DB when the cached value is empty while loggedIn: true).
Also relevant context: this build runs with a recent whatsmeow that performs the LID migration (the PairSuccess payload now includes both ID (@s.whatsapp.net) and LID (@lid)); the phone JID is still available in the DB, only the /session/status cache read is empty.
Summary
After a successful QR pairing,
GET /session/statusreturns"jid": ""even thoughconnected: trueandloggedIn: true, and even though theusers.jidcolumn in the database holds the correct JID. The JID is written to the DB onPairSuccess, but the in-memory userinfo cache that/session/statusreads from is not refreshed, so the endpoint keeps returning an emptyjiduntil the process is restarted (on restart the cache is loaded from the DB and the value appears again).This breaks integrations that rely on
/session/status.jidto learn the connected phone number right after pairing.Environment
70642149a0e8a81d49caa640f557217e03e09729(branchmain)v0.0.0-20260721154117-8b4a8ba0d318(latest at build time)CGO_ENABLED=0,GOOS=linux, DB backend: PostgreSQLSteps to reproduce
/session/connect).PairSuccessfires and is logged with the correct JID.GET /session/statuswith the user token.Expected
/session/statusreturns the paired JID:{ "connected": true, "loggedIn": true, "jid": "7989XXXXXXX:65@s.whatsapp.net", ... }Actual
jidis empty although the session is logged in:{ "connected": true, "loggedIn": true, "jid": "", ... }Evidence
Logs at pairing time — JID is correctly computed and written to the DB:
A couple of seconds later,
/session/statusreads from the cache and gets nothing:Database confirms the JID is stored (so it is purely a read/cache issue, not a write issue):
Notes / likely cause
It looks like
PairSuccesspersists the JID to the DB but does not update the cached userinfo entry that the/session/statushandler reads (userInfo.Get("Jid")). A process restart repopulates the cache from the DB, which is why the value reappears only after a restart.Possible fixes:
PairSuccess/Connected), or/session/statusread the JID from the DB (or fall back to the DB when the cached value is empty whileloggedIn: true).Also relevant context: this build runs with a recent whatsmeow that performs the LID migration (the
PairSuccesspayload now includes bothID(@s.whatsapp.net) andLID(@lid)); the phone JID is still available in the DB, only the/session/statuscache read is empty.