fix(whatsapp): stop reconnect failing when the token lists several WABAs - #1094
Draft
viethung0o0 wants to merge 1 commit into
Draft
fix(whatsapp): stop reconnect failing when the token lists several WABAs#1094viethung0o0 wants to merge 1 commit into
viethung0o0 wants to merge 1 commit into
Conversation
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
debug_tokenasgranular_scopes[whatsapp_business_management].target_ids[0]. A system-user token lists every WABA the business has shared with the app, and Meta does not keep that order stable between tokens, so the first entry only matched by luck.wabaIdagainst the whole list instead of the first entry.Changes
integrations/whatsapp/src/api/auth.ts:getSharedWabaId→getSharedWabaIds, returning every granted WABA id (the single-id helper had no remaining callers).apps/builder/src/features/integration-whatsapp/libs/waba-grant.ts:resolveGrantedWabaId/requireGrantedWabaIdwith aWABA_GRANT_FAILURESmap, shared by connect and reconnect so the selection rule lives in one place.actions/reconnect.action.ts: accepts the reconnect when the existing WABA is anywhere in the grant list; still rejects when the token does not cover it.actions/connect.action.ts:deriveSignupTargetstakes the requestedwabaIdand uses the same helper; the separate first-entry mismatch check is removed.whatsapp-waba-grant.test.ts(new), multi-WABA cases inwhatsapp-reconnect-action.test.ts,whatsapp-connect-action-registration.test.ts, andintegrations/whatsapp/__tests__/auth.test.ts.Test plan
pnpm lintpnpm --filter builder check-types && test(402 files / 2704 tests)pnpm --filter @chatbotx.io/integration-whatsapp check-types && test(24 files / 217 tests)