{"record":{"id":"875ebb2010ad4fb4","repo":"zeroclaw-labs/zeroclaw","slug":"failed-to-detect-notion-database-schema-e","errorCode":null,"errorMessage":"Failed to detect Notion database schema: {e}","messagePattern":"Failed to detect Notion database schema: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-channels/src/notion.rs","lineNumber":383,"sourceCode":"            .await?;\n        self.release_task(page_id).await;\n        Ok(())\n    }\n\n    async fn listen(&self, tx: tokio::sync::mpsc::Sender<ChannelMessage>) -> Result<()> {\n        // Detect status property type\n        match self.detect_status_type().await {\n            Ok(st) => {\n                ::zeroclaw_log::record!(\n                    INFO,\n                    ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note)\n                        .with_attrs(::serde_json::json!({\"st\": st})),\n                    \"status property type\"\n                );\n                *self.status_type.write().await = st;\n            }\n            Err(e) => {\n                bail!(\"Failed to detect Notion database schema: {e}\");\n            }\n        }\n\n        // Crash recovery\n        if self.recover_stale\n            && let Err(e) = self.recover_stale().await\n        {\n            ::zeroclaw_log::record!(\n                ERROR,\n                ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)\n                    .with_outcome(::zeroclaw_log::EventOutcome::Failure)\n                    .with_attrs(::serde_json::json!({\"error\": format!(\"{}\", e)})),\n                \"stale task recovery failed\"\n            );\n        }\n\n        // Polling loop\n        loop {","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-channels/src/notion.rs#L365-L401","documentation":"On startup, `listen` probes the configured Notion database to detect the status property type (`detect_status_type`); if that schema probe fails, listening aborts with this wrapped error. The inner `{e}` is almost always the `API error {status}` from the probe — invalid database ID, or a database the integration cannot see (401/403/404).","triggerScenarios":"`NotionChannel::listen` with a `database_id` that is wrong, contains URL junk (`?v=`, `Notion.so/` prefix), or refers to a database that was never shared with the integration.","commonSituations":"Pasting the full database URL instead of the raw ID; database duplicated/moved/deleted so the old ID is gone; integration access revoked from the database.","solutions":["Use the raw 32-character database ID — strip the URL prefix and `?v=` query","In Notion, open the database → ⋯ → Connections and add your integration","Verify access before starting: `curl -H \"Authorization: Bearer <api_key>\" -H \"Notion-Version: 2022-06-28\" https://api.notion.com/v1/databases/<id>`","Read the inner `{e}` text for the precise HTTP status"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let resp = client\n    .get(format!(\"https://api.notion.com/v1/databases/{database_id}\"))\n    .header(\"Authorization\", format!(\"Bearer {api_key}\"))\n    .header(\"Notion-Version\", \"2022-06-28\")\n    .send()\n    .await?;\nif !resp.status().is_success() {\n    return Err(anyhow::anyhow!(\n        \"notion database {database_id} not accessible: {}\",\n        resp.status()\n    ));\n}","typeGuard":null,"tryCatchPattern":"match notion_channel.listen(tx).await {\n    Err(e) if e.to_string().contains(\"Failed to detect Notion database schema\") => {\n        // inspect the inner {e}: 401/403/404 means fix database_id or integration sharing\n    }\n    other => other,\n}","preventionTips":["Probe database accessibility with one GET before starting the listener","Share every target database with the integration (⋯ → Connections) at setup time","Store only the raw 32-char database ID in config and lint against URL-shaped values"],"tags":["notion","schema","database-access","rust"],"backgroundTag":"database-access-denied","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}