omi
omi copied to clipboard
[Plugin Bug & Reliability] omi-notion-app: Identifier hygiene, Notion URL/Modal-peek extraction, page title disambiguation, and adaptive database schemas
Summary
Currently, plugins/omi-notion-app experiences several reliability, usability, and correctness issues when interacting with Notion pages, databases, and blocks:
- Identifier Fragility & Notion URL Failure: Users and LLM tools frequently provide Notion URLs (e.g.,
https://www.notion.so/workspace/Page-8a99478f6b214f1b857c2b28cf9c9a29?pvs=4or 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. - 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, andtool_append_contentonly accepted exact hex IDs, causing immediate failures or false 404s for common conversational requests. - Hardcoded Database Title Property ("Name"): When creating a database page,
tool_create_pagehardcoded 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 with400 Validation Error: Property Name does not exist. - Destructive Boolean Misparsing on Unarchive: Passing string representations like
"archive"toupdate_pageinadvertently parsed toFalsedue to naive boolean casting, unintentionally unarchiving documents. - 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
- 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. - 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. - Adaptive Database Schema Resolution:
tool_create_pagedynamically inspects the database schema (GET /databases/{id}) to detect the actual title property key before constructing the payload, falling back to"Name"gracefully. - 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. - Exception Transparency & Input Hygiene: Added planning error propagation (
ValueError) intool_append_content, guardedmax_resultsagainstnullvalues, and hardened parent/database ID cleaning. - Hermetic Test Suite: Added 33 hermetic unit tests in
test_page_disambiguation.pycovering 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]
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!