{"record":{"id":"f43c88662159b5d4","repo":"siyuan-note/siyuan","slug":"content-block-with-id-s-not-found-f43c88","errorCode":null,"errorMessage":"Content block with id [%s] not found","messagePattern":"Content block with id \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/blockial.go","lineNumber":100,"sourceCode":"\tif \"0\" != timed {\n\t\tt, e := dateparse.ParseIn(timed, time.Now().Location())\n\t\tif nil != e {\n\t\t\treturn e\n\t\t}\n\t\ttimedMills = t.UnixMilli()\n\t}\n\n\tFlushTxQueue()\n\n\tattrs := sql.GetBlockAttrs(id)\n\ttree, err := LoadTreeByBlockID(id)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tnode := treenode.GetNodeInTree(tree, id)\n\tif nil == node {\n\t\treturn fmt.Errorf(Conf.Language(15), id)\n\t}\n\n\tif ast.NodeDocument != node.Type && node.IsContainerBlock() {\n\t\tnode = treenode.FirstLeafBlock(node)\n\t}\n\n\tcontent := sql.NodeStaticContent(node, nil, false, false, false)\n\tcontent = gulu.Str.SubStr(content, 128)\n\tcontent = strings.ReplaceAll(content, editor.Zwsp, \"\")\n\terr = SetCloudBlockReminder(id, content, timedMills)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tattrName := \"custom-reminder-wechat\"\n\tif \"0\" == timed {\n\t\tdelete(attrs, attrName)\n\t\told := node.IALAttr(attrName)","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/blockial.go#L82-L118","documentation":"In SetBlockReminder, after FlushTxQueue + LoadTreeByBlockID(id) succeeds, treenode.GetNodeInTree(tree, id) returns nil and the function returns fmt.Errorf(Conf.Language(15), id) — 'Content block with id [%s] not found'. This means the blocktree (blocktree.db) has a row for the id, but the node is absent from the loaded .sy tree: the in-memory/SQLite index and the on-disk tree are out of sync. It is distinct from LoadTreeByBlockID failing outright (which returns a different error earlier at blockial.go:94).","triggerScenarios":"POST /api/block/setBlockReminder with an id whose blocktree entry references a tree that no longer contains the node — e.g. the node was removed by another client and not yet re-indexed, a data-repo reset left a stale blocktree, manual edits to .sy files, or a partially-completed sync.","commonSituations":"Holding a block id across a sync/reload cycle; using an id copied from an older document snapshot; index corruption after an unclean shutdown; referencing a block that was just deleted in the same transaction but the caller still has its id.","solutions":["Re-resolve the id: call /api/block/getBlockInfo or /api/block/getDocInfo with the id and confirm it is still live before setting a reminder.","If stale broadly, run /api/system/uiproc (reload UI) or trigger a reindex via /api/filetree/upsertIndexes / reindex so the blocktree matches disk.","If the block was legitimately deleted, stop referencing the id and obtain the current equivalent block id."],"exampleFix":"// before\nerr := model.SetBlockReminder(id, timed)\n\n// after: confirm the node is actually in the tree before calling\ntree, _ := model.LoadTreeByBlockID(id)\nif tree == nil || treenode.GetNodeInTree(tree, id) == nil {\n    return fmt.Errorf(Conf.Language(15), id)\n}\nerr := model.SetBlockReminder(id, timed)","handlingStrategy":"validation","validationCode":"// Confirm the node is present in its loaded tree before setting the reminder.\ntree, err := model.LoadTreeByBlockID(id)\nif err != nil || tree == nil || treenode.GetNodeInTree(tree, id) == nil {\n    return fmt.Errorf(model.Conf.Language(15), id)\n}","typeGuard":null,"tryCatchPattern":"// HTTP caller: treat Language(15) / 'not found' as stale-id and re-resolve.\nconst r = await fetchSyncPost('/api/block/setBlockReminder', {id, timed})\nif (r.code === -1 && r.msg.includes('not found')) {\n    const fresh = await refetchBlockId(id)\n    if (fresh) await fetchSyncPost('/api/block/setBlockReminder', {id: fresh, timed})\n}","preventionTips":["Never cache block ids across sync/reload cycles; re-query before mutating.","Trigger a notebook reindex when 'not found' errors appear for ids that should exist.","Avoid scheduling reminders against ids of blocks that are candidates for deletion."],"tags":["blockial","stale-index","block-not-found","reminder"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}