From d84ef4cfd62b1556b8038bf2f65b6724b99ef585 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma <32020192+tds-1@users.noreply.github.com> Date: Thu, 26 Mar 2026 15:00:09 +0530 Subject: [PATCH] fix(whatsapp): skip health check during reauthorization flow (#13911) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After a successful WhatsApp OAuth reauthorization, the health check runs immediately and finds the phone number in a pending provisioning state (`platform_type: NOT_APPLICABLE`). This incorrectly triggers `prompt_reauthorization!`, re-setting the Redis disconnect flag and sending a disconnect email — even though the reauth just succeeded. The fix skips the health check during reauthorization flows. It still runs for new channel creation. Closes https://github.com/chatwoot/chatwoot/pull/12556 ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How to reproduce 1. Have a WhatsApp channel with a phone number in pending provisioning state (display name not yet approved by Meta) 2. Complete the OAuth reauthorization flow 3. Observe that the user receives a "success" response but immediately gets a disconnect email ## What changed - `Whatsapp::EmbeddedSignupService#perform` now skips `check_channel_health_and_prompt_reauth` when `inbox_id` is present (reauthorization flow) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- app/services/whatsapp/embedded_signup_service.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/services/whatsapp/embedded_signup_service.rb b/app/services/whatsapp/embedded_signup_service.rb index 52273bc5d..1a5b13c8f 100644 --- a/app/services/whatsapp/embedded_signup_service.rb +++ b/app/services/whatsapp/embedded_signup_service.rb @@ -21,7 +21,10 @@ class Whatsapp::EmbeddedSignupService # 2. We need to run check_channel_health_and_prompt_reauth after webhook setup completes # 3. The channel is marked with source: 'embedded_signup' to skip the after_commit callback channel.setup_webhooks - check_channel_health_and_prompt_reauth(channel) + # Skip health check during reauthorization — phone numbers in pending provisioning state + # (platform_type: NOT_APPLICABLE) would incorrectly trigger a disconnect email right after + # a successful reauth. Only run health check for new channel creation. + check_channel_health_and_prompt_reauth(channel) if @inbox_id.blank? channel rescue StandardError => e