Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(api): delete notebooks with null slugs

tianma-if5dee03b2de0c
diff --git a/apps/api/src/notebook-service.test.mjs b/apps/api/src/notebook-service.test.mjs
index 7d3e22a3..5ddaa4cb 100644
--- a/apps/api/src/notebook-service.test.mjs
+++ b/apps/api/src/notebook-service.test.mjs
@@ -239,9 +239,9 @@ describe("notebook identity", () => {
const fixture = createFixture();
try {
fixture.sqlite.exec(`
- UPDATE notebooks SET name = '注册考试' WHERE id = 'nb_notes';
+ UPDATE notebooks SET name = '注册考试', slug = NULL WHERE id = 'nb_notes';
INSERT INTO notebooks (id, workspace_id, parent_id, name, slug, is_deleted, created_at, updated_at) VALUES
- ('nb_law', 'ws_1', 'nb_notes', '法律法规', 'law', 0, '2026-09-10T00:00:00.000Z', '2026-09-10T00:00:00.000Z'),
+ ('nb_law', 'ws_1', 'nb_notes', '法律法规', NULL, 0, '2026-09-10T00:00:00.000Z', '2026-09-10T00:00:00.000Z'),
('nb_history', 'ws_1', 'nb_notes', '建筑史', 'history', 0, '2026-09-10T00:00:00.000Z', '2026-09-10T00:00:00.000Z'),
('nb_outline', 'ws_1', 'nb_history', '大纲', 'outline', 0, '2026-09-10T00:00:00.000Z', '2026-09-10T00:00:00.000Z');
INSERT INTO memos (id, workspace_id, notebook_id, title, is_deleted, updated_at)
diff --git a/apps/api/src/notebook-service.ts b/apps/api/src/notebook-service.ts
index e818b47f..b6e4729c 100644
--- a/apps/api/src/notebook-service.ts
+++ b/apps/api/src/notebook-service.ts
@@ -324,7 +324,7 @@ export const deleteNotebookRecord = async (
`UPDATE notebooks
SET is_deleted = 1, deleted_at = ?, updated_at = ?
WHERE workspace_id = ? AND is_deleted = 0 AND id IN (${placeholders})
- AND slug <> 'inbox' AND id <> 'nb_inbox' AND id <> ?`
+ AND (slug IS NULL OR slug <> 'inbox') AND id <> 'nb_inbox' AND id <> ?`
).bind(now, now, workspaceId, ...chunk, inboxId);
});
statements.push(auditStatement(db, actor.actorType, actor.actorId, "notebook.delete", "notebook", id, {