Symptom
kbx sync notion against the internal Notion API (notion.so/api/v3/search) returns a hard server-side cap on results. Pagination loop in kb/sync/notion.py:670-694 follows the paginationToken from each response, but the API stops returning new pages well before all matching results are covered. Resulting backfills miss meetings silently.
Observed: multiple httpx.HTTPStatusError: 502 Bad Gateway and truncated result sets when running larger --since windows. After ~100 results across pages, syncs return either 502 or empty.
Current state
Disabled in cron on 2026-05-18 (scripts/kb-sync-cron.sh:46-52, in consumer repo) pending a fix. CLI command kbx sync notion still exists and is callable, but unsafe for unattended runs.
Why it's broken
Notion's internal /search endpoint (used by the web app for typeahead) is not designed as a backfill/export API. It:
- Caps results server-side regardless of
paginationToken
- Returns 502s under any load that resembles bulk pagination
- Has no documented contract — could change without notice
Fix options
- Move to official Notion API (
https://api.notion.com/v1/search): documented pagination via next_cursor, OAuth + integration token auth, predictable rate limits (3 req/sec). Requires installing a Notion integration in the workspace and switching auth model.
- Patch the internal
/search call: switch payload type from BlocksInSpace to a narrower query, batch by date range slices (e.g., 7-day windows) instead of relying on pagination. Stopgap only.
Affected code
src/kb/sync/notion.py:203-249 — Client.search_pages
src/kb/sync/notion.py:670-694 — pagination loop in sync_notion
- CLI:
kbx sync notion
Acceptance
kbx sync notion --since <30d ago> completes without 502 and returns the same set of pages a human would see in the workspace
- Re-enable in consumer cron
Restored from prior issue #109 after repository history rewrite (PII remediation, 2026-05-27).
Symptom
kbx sync notionagainst the internal Notion API (notion.so/api/v3/search) returns a hard server-side cap on results. Pagination loop inkb/sync/notion.py:670-694follows thepaginationTokenfrom each response, but the API stops returning new pages well before all matching results are covered. Resulting backfills miss meetings silently.Observed: multiple
httpx.HTTPStatusError: 502 Bad Gatewayand truncated result sets when running larger--sincewindows. After ~100 results across pages, syncs return either 502 or empty.Current state
Disabled in cron on 2026-05-18 (
scripts/kb-sync-cron.sh:46-52, in consumer repo) pending a fix. CLI commandkbx sync notionstill exists and is callable, but unsafe for unattended runs.Why it's broken
Notion's internal
/searchendpoint (used by the web app for typeahead) is not designed as a backfill/export API. It:paginationTokenFix options
https://api.notion.com/v1/search): documented pagination vianext_cursor, OAuth + integration token auth, predictable rate limits (3 req/sec). Requires installing a Notion integration in the workspace and switching auth model./searchcall: switch payloadtypefromBlocksInSpaceto a narrower query, batch by date range slices (e.g., 7-day windows) instead of relying on pagination. Stopgap only.Affected code
src/kb/sync/notion.py:203-249—Client.search_pagessrc/kb/sync/notion.py:670-694— pagination loop insync_notionkbx sync notionAcceptance
kbx sync notion --since <30d ago>completes without 502 and returns the same set of pages a human would see in the workspaceRestored from prior issue #109 after repository history rewrite (PII remediation, 2026-05-27).