Repository navigation
fix(ibge/uf): accept numeric IBGE codes in mapUfToUfCode - #823
Closed
mateussiqueira wants to merge 1 commit into
Closed
mateussiqueira wants to merge 1 commit into
mateussiqueira wants to merge 1 commit into
Conversation
getUfEstimatePopulationByCode calls mapUfToUfCode internally, which only handled state abbreviations (PI, SC). When a numeric code like '22' was passed, it threw NotFoundError and caused the entire Promise.all in the handler to reject with 404. Add a reverse lookup (CODE_TO_UF) so numeric codes are resolved to their state abbreviation first, then mapped to the expected numeric code. Fixes BrasilAPI#798
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed with the following error: |
|
Member
|
Oi @mateussiqueira! Obrigado pela contribuição! 🙏 Esse mesmo bug (IBGE UF por código numérico) tem 3 PRs concorrentes: #799, #820 e #823. Após compararmos, decidimos seguir com o #820, que tem o fix enxuto e cobre com teste unitário dedicado ( Fechando este PR em favor do #820. Se discordar, comenta aqui que a gente reavalia! 💪 |
Closed
20 tasks done
This branch had an error being deployed
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.



Problema
O endpoint
/api/ibge/uf/v1/:codefoi projetado para aceitar tanto sigla (PI) quanto código numérico IBGE (22), mas retorna 404 quando um código numérico é passado.Causa raiz
getUfEstimatePopulationByCodechamamapUfToUfCodeinternamente, que só aceitava siglas (PI, SC). Quando recebia22, não encontrava no mapa e lançavaNotFoundError$, fazendo oPromise.all` no handler rejeitar e a request inteira retornar 404.Solução
Adiciona um reverse lookup (
CODE_TO_UF) derivado doUF_CODE_MAPPER. Quando a entrada não é encontrada como sigla mas é um valor numérico, faz a busca reversa para resolver a sigla correspondente e retorna o código numérico esperado.Closes #798