omi icon indicating copy to clipboard operation
omi copied to clipboard

[Plugin Bug & Reliability] omi-notion-app: Identifier hygiene, Notion URL/Modal-peek extraction, page title disambiguation, and adaptive database schemas

Open shuoYun114 opened this issue 2 months ago • 1 comments

Summary

Currently, plugins/omi-notion-app experiences several reliability, usability, and correctness issues when interacting with Notion pages, databases, and blocks:

  1. Identifier Fragility & Notion URL Failure: Users and LLM tools frequently provide Notion URLs (e.g., https://www.notion.so/workspace/Page-8a99478f6b214f1b857c2b28cf9c9a29?pvs=4 or modal peek URLs .../Tasks-<db_id>?p=<page_id>&pm=s), formatted prefixes (page:8a..., #8a...), or untyped primitives. Handlers passed these raw strings directly to Notion API endpoints, resulting in 404s or invalid request errors.
  2. Missing Page Title Disambiguation: In voice and conversational flows, users reference pages by title (e.g., "Add notes to my Weekly Sync"). Previously, tool_get_page, tool_update_page, and tool_append_content only accepted exact hex IDs, causing immediate failures or false 404s for common conversational requests.
  3. Hardcoded Database Title Property ("Name"): When creating a database page, tool_create_page hardcoded the title property name as "Name". In user workspaces, database title properties are frequently renamed to "Task", "Title", "Project", or localized equivalents, causing Notion API to reject page creation with 400 Validation Error: Property Name does not exist.
  4. Destructive Boolean Misparsing on Unarchive: Passing string representations like "archive" to update_page inadvertently parsed to False due to naive boolean casting, unintentionally unarchiving documents.
  5. Language & Formatting Boundary Gaps: CJK (Chinese, Japanese, Korean) page titles failed regex word-boundary checks, and zero-width characters/combining marks prevented deterministic title matching.

Proposed Fix

  1. Identifier Hygiene & URL Extraction: Implement sanitize_notion_id(raw) supporting 32-hex, hyphenated 36-UUID, Notion web URLs, modal peek query params (?p=...), and prefix stripping, with strict type filtering to prevent dirty object injection.
  2. Two-Tier Page Title Disambiguation: Implement disambiguate_page_by_title(uid, query) with Unicode NFKC normalization, format-control stripping, and casefold matching. Tier 1 matches exact titles; Tier 2 supports word-boundary, prefix, and CJK continuous substring matching (>= 2 chars). Excludes archived pages and strictly blocks ambiguous collisions with candidate lists to prevent destructive mutations.
  3. Adaptive Database Schema Resolution: tool_create_page dynamically inspects the database schema (GET /databases/{id}) to detect the actual title property key before constructing the payload, falling back to "Name" gracefully.
  4. Safe Boolean Parsing: Implement closed two-way boolean validation ({"true", "1", "yes", "archive", "archived"} vs {"false", "0", "no", "unarchive", "unarchived"}), rejecting invalid strings with clear error messages.
  5. Exception Transparency & Input Hygiene: Added planning error propagation (ValueError) in tool_append_content, guarded max_results against null values, and hardened parent/database ID cleaning.
  6. Hermetic Test Suite: Added 33 hermetic unit tests in test_page_disambiguation.py covering all edge cases (0.02s execution, 0 external network calls). All 65 Notion tests and 52 repo checks pass cleanly.

Bounty Proposal

  • Proposed Bounty: $50 (Backend Plugin Reliability & Feature Enhancement)
  • Preferred Payment (USDT-TRC20): TGKmfSUmt2dggErAo8BicaCoXhkMwLetxV
  • Alternative Payment (BTC): 1NkUnv23H65ZYJn64pseAcWRA6sJitxh2f
  • Email: [email protected]

shuoYun114 avatar Sep 17 '26 14:09 shuoYun114

Locking this task / bounty.

As an active contributor with merged PRs (#14224, #14546), claiming lock privilege per official Omi Contribution Guidelines:

  • Clean implementation is submitted in PR #14348: https://github.com/BasedHardware/omi/pull/14348
  • Robust identifier sanitization, two-tier page title disambiguation, and adaptive database schemas.
  • Already reviewed and APPROVED by maintainer @kodjima33 with 17/17 CI checks passing 100% green. Awaiting squash & merge!

shuoYun114 avatar Sep 19 '26 02:09 shuoYun114