Repository navigation
fix(utils): prevent stripping 9th digit on Brazilian mobile numbers with DDD >= 31 - #208
alejandro-mero wants to merge 1 commit into
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR fixes Brazilian mobile JID generation by removing the legacy rule that stripped the 9th digit for DDDs >= 31. Flow diagram for Brazilian number preservationflowchart TD
A[Caller provides Brazilian number] --> B[formatBRNumber]
B --> C[Return jid unchanged]
C --> D[whatsmeow uses full 13-digit JID]
D --> E[Message addresses registered WhatsApp number]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If preserving the ninth digit is wrong for some Brazilian numbers, messages may fail to reach the intended WhatsApp account or could be routed to a different account, and any messages already sent cannot be undone by reverting. The impact is bounded to affected Brazilian recipients and is normally repairable by correcting the formatting and retrying.
…evolution-foundation#196 e evolution-foundation#208) Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Prevents
formatBRNumberfrom unconditionally stripping the 9th digit on Brazilian mobile numbers when DDD >= 31.Problem
In
pkg/utils/utils.go,formatBRNumberwas stripping the 9th digit for any 13-digit Brazilian mobile number where DDD >= 31 (e.g. Paraná DDD 45, Santa Catarina DDD 48, Minas Gerais DDD 31, etc.):Historically, WhatsApp mapped some older Brazilian accounts outside DDD 11–28 with 8-digit JIDs. However, all Brazilian mobile lines nationwide have had 9 digits since Anatel completed the rollout in 2016. Modern WhatsApp accounts are registered natively with the full 9 digits.
When sending a message to a modern 13-digit number (e.g.,
5545920031456),formatBRNumberstrips the9, converting it to+554520031456@s.whatsapp.net. Because that 8-digit variant does not exist on WhatsApp, the server returns an HTTP 500 error:{"error":"number +554520031456@s.whatsapp.net is not registered on WhatsApp"}.Solution
Preserve the 13-digit number provided by the caller so
whatsmeowcan address the user with their legitimate JID without mutating the digits.pkg/utils/utils_test.goupdated and passing.Summary by Sourcery
Preserve modern Brazilian mobile numbers without removing their 9th digit.
Bug Fixes:
Tests: