Skip to content

fix(notion): align integration with live API docs, add block retrieval coverage#5491

Merged
waleedlatif1 merged 4 commits into
stagingfrom
validate/notion-integration
Jul 7, 2026
Merged

fix(notion): align integration with live API docs, add block retrieval coverage#5491
waleedlatif1 merged 4 commits into
stagingfrom
validate/notion-integration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed notion_update_page being registered and wired in tools.access/tools.config.tool but completely unreachable in the UI — no dropdown option or subBlocks existed for it
  • Fixed legacy NotionBlock outputs only declaring content/metadata, leaving 9 of 17 operations (add row, append/retrieve/update/delete block, comments, users) with no matching outputs
  • Added .trim() on ID params (pageId, databaseId, parentId) used directly in request URLs across 8 tool files to guard against copy-paste whitespace
  • Removed incorrect required: true on content for notion_create_page — Notion allows title-only page creation
  • Removed a dead, unused NotionReadDatabaseParams interface shadowed by the real one in read_database.ts
  • Added notion_retrieve_block/notion_retrieve_block_v2 (GET /v1/blocks/{id}) — we had update/delete/append/retrieve-children for blocks but no way to fetch a single block's content directly
  • No OAuth scope changes — Notion's OAuth model has no scopes (access is governed by page/database sharing + integration capabilities), confirmed scopes: [] is correct and unchanged

Type of Change

  • Bug fix

Testing

Tested manually — validated every tool against live Notion API docs, ran full validate-integration checklist (tool params, block↔tool alignment, conditions, outputs, OAuth scopes).

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…l coverage

- wire up notion_update_page in the block (was registered but unreachable — no dropdown option or subBlocks)
- fix legacy NotionBlock outputs to cover all 17 operations, not just content/metadata
- trim ID params (pageId, databaseId, parentId) before use in request URLs across 8 tool files
- remove content required:true on create_page (Notion allows title-only pages)
- remove dead unused NotionReadDatabaseParams interface
- add notion_retrieve_block/_v2 tool for GET /v1/blocks/{id}, filling a gap in block CRUD coverage
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 7, 2026 8:47pm

Request Review

@cursor

cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches many Notion workflow paths and changes legacy block output shapes by operation, which could affect existing workflows that relied on missing or generic outputs; changes are largely additive fixes with no OAuth scope changes.

Overview
This PR tightens the Notion integration so tools, blocks, and docs match the live API and workflows can use operations that were previously half-wired.

New and exposed capabilities: Adds notion_retrieve_block / _v2 (GET /v1/blocks/{id}) and wires it through the block dropdown, registry, and docs. notion_update_page is now usable in the UI (operation, page picker, JSON properties) instead of only being registered in tool config. startCursor pagination is supported on query database and search in tools, advanced block fields, and integration docs.

Reliability and UX fixes: Notion IDs used in request URLs are .trim()’d across read/write/create/update and related tools to avoid copy-paste whitespace failures. Create page no longer requires content in the block (title-only pages). Legacy NotionBlock outputs are split by operation so block/comment/user/block ops expose flat fields (id, results, block, has_children, etc.), not only content/metadata; Notion v2 output conditions are aligned similarly.

Cleanup: Removes dead/unused type helpers in types.ts and drops a shadow NotionReadDatabaseParams interface.

Reviewed by Cursor Bugbot for commit 040d6e7. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR closes a set of alignment gaps between the Notion integration's UI, tool registry, and live API docs: notion_update_page was registered but unreachable, nine operations were missing outputs in the legacy block, and there was no tool to fetch a single block's content (GET /v1/blocks/{id}).

  • notion_retrieve_block / notion_retrieve_block_v2 — new tools covering the missing GET /v1/blocks/{id} endpoint; correctly trimmed, wired into both legacy and V2 blocks with full output conditions (id, type, has_children, archived, block).
  • Legacy NotionBlock overhaulnotion_update_page added to the dropdown with its properties sub-block and output conditions; nine previously output-less operations (add_row, append/retrieve/update/delete block, comments, users) now expose the correct flat output fields with per-operation conditions.
  • Whitespace hardening & pagination.trim() added to all ID params used in request URLs across eight tool files; startCursor pagination param added to query_database and search.

Confidence Score: 5/5

Safe to merge — changes are additive fixes to the Notion integration with no breaking API surface changes.

All changes are additive: new tools, new output conditions, and whitespace guards. The legacy block and V2 block are both correctly wired, the tool registry is updated, and the V2 versioned-selector pattern is followed consistently. The only finding is a documentation inaccuracy in the newly added docs section that does not affect runtime behavior.

apps/docs/content/docs/en/integrations/notion.mdx — the notion_retrieve_block output table lists all shared outputs rather than just what the tool returns.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/notion.ts Wires notion_update_page into the legacy block dropdown, adds notion_retrieve_block throughout, and expands output conditions so all newly-exposed operations have proper output fields in both legacy and V2 blocks.
apps/sim/tools/notion/retrieve_block.ts New tool implementing GET /v1/blocks/{id} — correctly trims blockId, uses response.ok for success flag, and shares its config with the V2 variant via object reference.
apps/sim/tools/notion/types.ts Removes dead/unused output constants and the shadowed NotionReadDatabaseParams interface; adds startCursor to query and search param types.
apps/sim/tools/registry.ts Registers notionRetrieveBlockTool and notionRetrieveBlockV2Tool in the tool registry under notion_retrieve_block and notion_retrieve_block_v2.
apps/docs/content/docs/en/integrations/notion.mdx New notion_retrieve_block section added, but its output table lists all 16 shared Notion outputs rather than the 5 fields the tool actually returns; existing sections have the same pattern.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User selects operation in Notion Block] --> B{Block version?}
    B -- Legacy NotionBlock --> C[getTool switch → notion_retrieve_block]
    B -- NotionV2Block --> D[createVersionedToolSelector\n operation + '_v2'\n → notion_retrieve_block_v2]
    C --> E[notionRetrieveBlockTool\nGET /v1/blocks/blockId.trim]
    D --> F[notionRetrieveBlockV2Tool\nshares request + transformResponse]
    E --> G[transformResponse\nsuccess: response.ok\noutput: id, type, has_children,\narchived, block]
    F --> G
    G --> H[Block outputs conditioned on\n'notion_retrieve_block'\nid · type · has_children\narchived · block]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[User selects operation in Notion Block] --> B{Block version?}
    B -- Legacy NotionBlock --> C[getTool switch → notion_retrieve_block]
    B -- NotionV2Block --> D[createVersionedToolSelector\n operation + '_v2'\n → notion_retrieve_block_v2]
    C --> E[notionRetrieveBlockTool\nGET /v1/blocks/blockId.trim]
    D --> F[notionRetrieveBlockV2Tool\nshares request + transformResponse]
    E --> G[transformResponse\nsuccess: response.ok\noutput: id, type, has_children,\narchived, block]
    F --> G
    G --> H[Block outputs conditioned on\n'notion_retrieve_block'\nid · type · has_children\narchived · block]
Loading

Reviews (4): Last reviewed commit: "fix(notion): document type-specific cont..." | Re-trigger Greptile

Comment thread apps/sim/tools/notion/retrieve_block.ts
…s, dead types, regen docs

- add missing startCursor/start_cursor pagination param to notion_query_database and notion_search
- fix notion_search missing from the shared pageSize/startCursor field's operation condition in NotionBlock
- fix NotionV2Block title/url/created_time/last_edited_time outputs rendering unconditionally for every operation instead of only the ones that return them
- remove 153 lines of dead unused output-shape constants from types.ts
- regenerate integration docs
type/block/archived only conditioned on notion_update_block/notion_delete_block,
and has_children was missing entirely — Retrieve Block's payload was invisible
in the legacy NotionBlock output picker (Greptile P1 on PR #5491).
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 98cc1ef. Configure here.

block.properties (BLOCK_OUTPUT_PROPERTIES) only covers common block fields,
not the type-specific sub-object (paragraph.rich_text, image.file, etc.) —
that varies per block type and isn't enumerable. Documented in the
description per Greptile P2 on PR #5491; no functional change, block: data
already carries the full object at runtime.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 040d6e7. Configure here.

@waleedlatif1 waleedlatif1 merged commit 61ceedc into staging Jul 7, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the validate/notion-integration branch July 7, 2026 20:57
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant