{{ message }}
Repository navigation
fix(whatsapp): treat empty phone fields as absent - #992
Merged
bensabic merged 1 commit intoOct 7, 2026
Merged
Conversation
Meta can send `from` and `wa_id` as empty strings, instead of omitting them, for a username user who does not share their phone number. The identity lookup used `??`, which keeps the empty string, so `fields()` returned no user ID and the webhook dropped the message with "WhatsApp message has no user identifier". A system message with an empty `from` also aliased the new BSUID to an empty user ID. Use `||` so an empty identifier falls through to the BSUID. Fixes vercel#925 Signed-off-by: Jon Bailey <297513015+Pitchfork-and-Torch@users.noreply.github.com>
Contributor
bensabic
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes #925.
Meta can send
fromandwa_idas empty strings, instead of omitting them, for a username user who doesn't share their phone number. An earlier revision of Meta's business-scoped user IDs page described both fields as "New value (empty)", and Azure Communication Services warns thatfrom"may be empty or null". The current Meta page says the fields are omitted. The adapter should handle both shapes.fields()resolved the user with??, which keeps"":So
resolve()returnednull, andhandleWebhookdropped the message withWhatsApp message has no user identifier, even thoughfrom_user_idwas present. Inresolve(), a system message withfrom: ""also set the canonical fallback to"", so the new BSUID was aliased to an empty user ID.This PR uses
||infields()and for the system-messagesourceinresolve(), so an empty identifier falls through to the BSUID. Payloads that omit the fields, or that carry a real phone number, resolve the same way as before.Test plan
Two regression tests in
packages/adapter-whatsapp/src/index.test.ts:from: "",wa_id: "", andfrom_user_idreachesprocessMessageonwhatsapp:123456789:<BSUID>. The reply is sent withrecipient: <BSUID>and noto.from: ""andsystem.user_id: "US.NEW", the alias forUS.NEWpoints toUS.NEW, not"".Both tests fail on
main:With only the
fields()change, the second test still fails withexpected '' to be 'US.NEW'. That failure is whyresolve()needs the change too.With the full fix:
pnpm --filter @chat-adapter/whatsapp test: 5 files, 232 tests passtsc --noEmitin the adapter: passesbiome checkon the changed files: no issuesChecklist
git commit -s)pnpm validatepasses (I ran the adapter's test suite, typecheck, and Biome check, not the full monorepo validate)sample-messages.mdnow says the phone fields can be empty strings)