Brazilian number rewrite in JID middleware breaks delivery to 9-digit mobiles
Los mantenedores suelen responder en 9 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 22/100
Línea de trabajo
Start with formatBRNumber in pkg/utils/utils.go, then trace how ValidateNumberFieldWithFormatJid in pkg/middleware/jid_validation_middleware.go rewrites the request body before validateAndCheckUserExists in pkg/sendMessage/service/send_service.go runs. Routing is in pkg/routes/routes.go. Done means a 9-digit Brazilian number is delivered without the caller setting formatJid false, and the contact and reaction routes handle formatJid consistently. The fix changes validation design, so confirm the approach with maintainers first.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
The JID validation middleware rewrites Brazilian numbers before any verification, and the rewrite is irreversible. This makes /send/* fail for mobile numbers whose WhatsApp registration includes the ninth digit — even though sendService already contains the correct logic to handle both cases.
Reproduced on tag 0.7.2; the relevant code is identical on main.
The rule
formatBRNumber (pkg/utils/utils.go) drops the first digit after the area code:
if firstDigitNum >= 7 && dddNum >= 31 {
return jid[:4] + jid[5:]
}
For DDD >= 31 this is applied unconditionally. It is correct for older mobile numbers from those regions (registered with 8 digits), but wrong for the newer 9-digit ranges, which only exist in full form.
Evidence
Using /user/check on the same number, which is the cleanest isolation since it exposes formatJid:
formatJid=true Query "+55469XXXXXXX" (digit dropped) IsInWhatsapp=false
formatJid=false Query "55469XXXXXXXX" (as sent) IsInWhatsapp=true,
JID [email protected]
With the default (formatJid unset → true), /send/text fails:
SendMessage called for number: [email protected]
Error validating message fields or user check: number [email protected] is not registered on WhatsApp
In our production data, 2,488 contacts have this shape. None of them could ever receive a message from the API until we started sending formatJid: false.
Why this is worth fixing upstream
validateAndCheckUserExists (pkg/sendMessage/service/send_service.go) already does the right thing: it calls checkSingleUserExists with formatJid=false, falls back to true if not found, and then messages the remoteJID that WhatsApp itself returned. That logic covers both the legacy 8-digit and the new 9-digit cases.
The problem is that it never sees the original number. ValidateNumberFieldWithFormatJid (pkg/middleware/jid_validation_middleware.go) rewrites the request body before the handler runs, and the dropped digit cannot be recovered — so the service's own fallback is checking two variants of an already-broken number.
Suggestion: let the middleware validate without mutating, and leave the formatting decision to validateAndCheckUserExists, which can verify against the server before committing to a JID.
Secondary issue: formatJid has no effect on some routes
In pkg/routes/routes.go, only /send/text|link|media|poll|sticker|location|button|list|carousel and /user/check use ValidateNumberFieldWithFormatJid. Notably:
/send/contactusesValidateContactFields(), which always normalizes — even thoughContactStructexposes aformatJidfield. The field is silently ignored, so sending a vCard to one of these numbers cannot be made to work./message/react,/markread,/markplayed,/presence,/delete,/edituseValidateNumberField()and expose noformatJidat all, so reacting to or marking as read a message from one of these contacts always fails.
Also worth noting: passing a full JID does not bypass the rewrite — validateMessageFields splits it back apart (strings.Split(phone, "@")[0]) and re-applies CreateJID.
- Lenguaje dominante
- Go
- Estrellas
- 1k
- Forks
- 610
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de evolution-foundation/evolution-go
-
/user/info and /user/avatar hang for 75s when number is a phone numberPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
evolution-foundation/evolution-go#223 ·
Los mantenedores suelen responder en 9 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
evolution-foundation/evolution-go#193 ·
Los mantenedores suelen responder en 9 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
evolution-foundation/evolution-go#104 ·
Los mantenedores suelen responder en 9 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
evolution-foundation/evolution-go#101 ·
Los mantenedores suelen responder en 9 días
-
POST /group/participant always returns 400 "participants is required and cannot be empty" (wrong validation middleware on route)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
evolution-foundation/evolution-go#97 · 2 comentarios ·
Los mantenedores suelen responder en 9 días
Todos los issues de evolution-foundation/evolution-go
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
kaiachain/kaia#1143 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
documentation factory:ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
good first issue spec
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
-
Go - Inconsistent Logs StabilityAbiertodocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
open-telemetry/opentelemetry.io#12846 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día