fix(weex): corrige falso negativo cuando el ServiceLayer falla - #10
Open
pachedev wants to merge 1 commit into
Open
fix(weex): corrige falso negativo cuando el ServiceLayer falla#10pachedev wants to merge 1 commit into
pachedev wants to merge 1 commit into
Conversation
Weex responde 200 con un sobre { obj, error: { code, message, retry } } y
su propio portal trata cualquier code distinto de 0 como fallo del
servicio, no como resultado vacío. El código leía
obj.dnActiveByCurpRfc.length === 0 sin mirar error.code, así que una
consulta que nunca llegó a ocurrir se le mostraba al usuario como "no
tienes líneas registradas a tu nombre". Es el espejo del falso positivo
que corrigió 6429f02 en Sorcel, sólo que en la dirección contraria.
Además obj.dnActiveByCurpRfc se accedía sin guardas, y en esos mismos
errores el sobre viene sin obj: lanza TypeError y tumba el provider
entero.
Ahora se comprueba error.code antes de interpretar el arreglo, se lee obj
con optional chaining para que un sobre inesperado no lance, y 403/429
pasan a temporaryUnavailable, que es lo que ya usan otros providers para
distinguir un bloqueo de un fallo real del operador.
Verificado ejecutando el código anterior y el nuevo sobre las mismas
respuestas. Con líneas y sin líneas se comportan igual, así que no hay
regresión en los caminos normales. Con error de negocio y el arreglo
vacío el anterior decía "sin registro" y el nuevo marca no disponible;
con el sobre sin obj el anterior lanzaba TypeError.
|
@pachedev is attempting to deploy a commit to the JMora Team on Vercel. A member of the Team first needs to authorize it. |
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.
Weex responde 200 con un sobre { obj, error: { code, message, retry } } y su propio portal trata cualquier code distinto de 0 como fallo del servicio, no como resultado vacío. El código leía
obj.dnActiveByCurpRfc.length === 0 sin mirar error.code, así que una consulta que nunca llegó a ocurrir se le mostraba al usuario como "no tienes líneas registradas a tu nombre". Es el espejo del falso positivo que corrigió 6429f02 en Sorcel, sólo que en la dirección contraria.
Además obj.dnActiveByCurpRfc se accedía sin guardas, y en esos mismos errores el sobre viene sin obj: lanza TypeError y tumba el provider entero.
Ahora se comprueba error.code antes de interpretar el arreglo, se lee obj con optional chaining para que un sobre inesperado no lance, y 403/429 pasan a temporaryUnavailable, que es lo que ya usan otros providers para distinguir un bloqueo de un fallo real del operador.
Verificado ejecutando el código anterior y el nuevo sobre las mismas respuestas. Con líneas y sin líneas se comportan igual, así que no hay regresión en los caminos normales. Con error de negocio y el arreglo vacío el anterior decía "sin registro" y el nuevo marca no disponible; con el sobre sin obj el anterior lanzaba TypeError.