omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(notion-app): get_page reads only the first 50 blocks and never follows next_cursor

Open Abhist17 opened this issue 2 months ago • 1 comments

Description

In plugins/omi-notion-app/main.py, tool_get_page reads a page's content with a single GET /blocks/{page_id}/children?page_size=50 and never looks at has_more / next_cursor. Notion pages block children (max 100 per page) and signals the remainder through next_cursor.

The rendered content is separately capped at 1,000 characters — but the two limits are unrelated, and the block limit wins far more often than the character cap:

  • only blocks with rich_text render to text (extract_text_content), so dividers, images, embeds, child pages, tables and the empty paragraphs people use as spacing all count toward the 50 while producing nothing;
  • to-do, bulleted and numbered lists render a handful of characters per block.

So an ordinary page with a few spacers/media, or any list-style page longer than 50 items, has everything after its 50th block silently dropped even though it would have fit in the 1,000-character budget — and the tool reports success with no sign anything is missing.

Evidence (current main): tool_get_page → notion_api_request(uid, "GET", f"/blocks/{page_id}/children", params={"page_size": 50}), then content[:1000]. No cursor handling anywhere on the read path (append_content_batches is the write path).

Proposed Fix

  1. fetch_page_blocks(uid, page_id): follow next_cursor (page size 100, Notion's maximum) until has_more is false or the rendered text reaches the content cap — so the cap is the only thing that truncates and no page beyond it is fetched. Page ceiling + repeated-cursor detection guard against a malformed cursor.
  2. A failure on a later page returns that page's error, so the existing fail-closed path from #13181 reports it — a read that failed halfway is never a shorter successful page.
  3. Regression tests in the existing test_main.py suite (already registered as notion-page-content-tests): the 51st block must appear, budget-met stops fetching, later-page HTTP/transport failure is an error, repeated cursor stops, page ceiling.

Same class as #13545 (github-app labels), #13810 (dropbox list_folder) and #13913 (ms365 calendarView).


Proposed Bounty Reward: $50.00 USD Bounty Payout Destination (PayPal): [email protected]

cc @josancamon19 @kodjima33

Abhist17 avatar Sep 14 '26 18:09 Abhist17

PR up: https://github.com/BasedHardware/omi/pull/13916

Happy to adjust anything — I'll turn review comments around the same day.

Abhist17 avatar Sep 15 '26 14:09 Abhist17