fix(notion_search): map legacy 'database' filter to 'data_source'#163
Merged
Conversation
A tool notion_search enviava filter.value='database' direto pra client.search. A API do Notion (versão 2025-09-03, multi-source databases) rejeita esse valor: `validation_error: body.filter.value should be 'page' or 'data_source', instead was 'database'` — erro recorrente nos logs de prod (ex.: workspace=nora). Fix: o enum do filtro aceita 'page', 'data_source' e o legado 'database' (o que os agentes aprenderam a mandar), e normalizeSearchFilter mapeia 'database' -> 'data_source' antes de chamar a API. O helper vive num módulo próprio sem side-effect (src/notion-search-filter.ts) pra ficar testável sem os tokens Notion que clients.ts exige no load. Obs: o SDK @notionhq/client 2.3.0 ainda tipa value como 'page'|'database' (o tipo do SDK está atrás da API — essa defasagem É o bug), então a chamada leva um cast pro valor runtime-correto. Teste: src/__tests__/notion-search-filter.test.ts cobre o enum e o mapeamento. Build + 1477 testes verdes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
ENG-1
A tool
notion_searchenviavafilter.value='database'direto praclient.search. A API do Notion (versão2025-09-03) rejeita esse valor:Erro recorrente nos logs de prod (
[notion_search] workspace=nora code=validation_error).Fix
page,data_sourcee o legadodatabase.normalizeSearchFiltermapeiadatabase->data_sourceantes de chamar a API.src/notion-search-filter.ts(sem side-effect) pra ficar testável.@notionhq/client@2.3.0ainda tipavaluecomo'page'|'database'(o tipo do SDK está atrás da API); a chamada leva um cast pro valor runtime-correto.Aceite
src/__tests__/notion-search-filter.test.ts(6 casos) cobre o enum e o mapeamento.npm run buildlimpo,npm test= 1477 pass / 0 fail.validation_errordedatabasesome dos logs.🤖 Generated with Claude Code