Repository navigation
fix(ibge): corrigir busca por código numérico e mensagem de erro no endpoint /ibge/uf/v1 - #799
Closed
felipeflfranca wants to merge 3 commits into
Closed
felipeflfranca wants to merge 3 commits into
felipeflfranca wants to merge 3 commits into
Conversation
A função mapUfToUfCode só aceitava siglas (PI, SC), rejeitando códigos numéricos (22, 42) com NotFoundError. Agora reconhece códigos numéricos válidos e os retorna diretamente. Também atualiza os testes para usar objectContaining, acomodando os campos populacao_estimada e periodo adicionados ao endpoint. Closes BrasilAPI#798 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
@felipeflfranca is attempting to deploy a commit to the BrasilAPI Team on Vercel. A member of the Team first needs to authorize it. |
mapUfToUfCode passava string ao construtor de NotFoundError, que espera
objeto { message }. Desestruturar string como objeto produz message
undefined, resultando em resposta com message vazia.
Mantém o valor da UF na mensagem para facilitar debug
(ex: "UF SJ não encontrada.").
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
felipeflfranca
force-pushed
the
fix/ibge-uf-numeric-code
branch
from
April 16, 2026 03:10
4dd3cf0 to
8aec000
Compare
Reduz duplicação apontada pelo SonarCloud extraindo o schema de validação de UF para uma constante reutilizada nos testes. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Contributor
Member
|
Oi @felipeflfranca! 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:
Fechando este PR em favor do #820. Se discordar, comenta aqui que a gente reavalia! 💪 |
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.



📋 Descrição
Duas correções no endpoint
/api/ibge/uf/v1/:code:Código numérico retornava 404: A função
mapUfToUfCodeemutil/mapUfToUfCode.jssó aceitava siglas (
PI,SC), rejeitando códigos numéricos (22,42) comNotFoundError. Agora reconhece códigos numéricos válidos e os retorna diretamente.Mensagem de erro vazia para UF inválida:
mapUfToUfCodepassava string aoconstrutor de
NotFoundError, que espera objeto{ message }. Isso produziamessage: ""na resposta. Agora passa o formato correto e mantém o valor dinâmico(ex:
"UF SJ não encontrada.").Também atualiza os testes para usar
objectContaining, acomodando os campospopulacao_estimadaeperiodoque foram adicionados ao endpoint após a criaçãodos testes.
🎯 Tipo de Mudança
📚 Checklist de Documentação
🧪 Checklist de Testes
💻 Checklist de Código
🚀 Checklist de Performance e Custos
🔍 Como Testar
curl https://brasilapi.com.br/api/ibge/uf/v1/22— hoje retorna 404, com o fix retorna200 (Piauí)
curl https://brasilapi.com.br/api/ibge/uf/v1/SJ— hoje retornamessage: "", com ofix retorna
message: "UF SJ não encontrada."curl https://brasilapi.com.br/api/ibge/uf/v1/PI— continua funcionando normalmente📎 Issues Relacionadas