Summary
Creating a new nav section directly under Notebook fails with Notion API 404 object_not_found because ensure_section passes the wiki database ID as a page ID.
Steps to reproduce
- Configure
notion_sync with a wiki database (database_id / data_source_id).
- Add a new section under
Notebook in .nav.yml (e.g. 音视频 with child notes).
- Run incremental or full sync for those notes.
Expected behavior
The tool creates the missing section page(s) under the Notebook wiki data source, then creates/updates child content pages.
Actual behavior
INFO create section 音视频 (Notebook/音视频)
ERROR FAIL obsidian/音视频/乐理基础.md: 404 object_not_found
message: Could not find page with ID: <database_id>
Other pages that already exist in .notion_sync_state.json still update successfully — this is not an integration permission problem.
Root cause
In mkdocs_note/utils/notion/sync.py, ensure_section:
- Resolves parent
Notebook to state.root_page_id (the database ID) — correct.
- Sets
parent_kind = "page" whenever item.parent_key is set — incorrect for Notebook.
create_page then sends {"parent": {"page_id": "<database_id>"}}, which Notion rejects.
resolve_parent_id already special-cases Notebook children to use data_source / database parent kinds; ensure_section does not.
Proposed fix
When the resolved parent is the Notebook root, use the same logic as resolve_parent_id:
parent_id = state.data_source_id or state.root_page_id
parent_kind = "data_source" if state.data_source_id else "database"
Apply this in ensure_section when parent_key points to Notebook (or when parent_id == state.root_page_id).
Acceptance criteria
Environment
mkdocs-note==3.3.0
- Notion API
2025-09-03 (pages)
References
mkdocs_note/utils/notion/sync.py — ensure_section, resolve_parent_id
mkdocs_note/utils/notion/client.py — create_page
Summary
Creating a new nav section directly under
Notebookfails with Notion API404 object_not_foundbecauseensure_sectionpasses the wiki database ID as a page ID.Steps to reproduce
notion_syncwith a wiki database (database_id/data_source_id).Notebookin.nav.yml(e.g.音视频with child notes).Expected behavior
The tool creates the missing section page(s) under the Notebook wiki data source, then creates/updates child content pages.
Actual behavior
Other pages that already exist in
.notion_sync_state.jsonstill update successfully — this is not an integration permission problem.Root cause
In
mkdocs_note/utils/notion/sync.py,ensure_section:Notebooktostate.root_page_id(the database ID) — correct.parent_kind = "page"wheneveritem.parent_keyis set — incorrect for Notebook.create_pagethen sends{"parent": {"page_id": "<database_id>"}}, which Notion rejects.resolve_parent_idalready special-cases Notebook children to usedata_source/databaseparent kinds;ensure_sectiondoes not.Proposed fix
When the resolved parent is the Notebook root, use the same logic as
resolve_parent_id:Apply this in
ensure_sectionwhenparent_keypoints to Notebook (or whenparent_id == state.root_page_id).Acceptance criteria
Notebookare created without 404.Projects) continue to work.ensure_sectionwith Notebook parent.Environment
mkdocs-note==3.3.02025-09-03(pages)References
mkdocs_note/utils/notion/sync.py—ensure_section,resolve_parent_idmkdocs_note/utils/notion/client.py—create_page