Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: The `updateBlock` API encountered a null pointer error https://github.com/siyuan-note/siyuan/issues/16705

Daniel89dc302694ea
diff --git a/kernel/api/block_op.go b/kernel/api/block_op.go
index 31b5567a8f..1d58fb9afd 100644
--- a/kernel/api/block_op.go
+++ b/kernel/api/block_op.go
@@ -25,6 +25,7 @@ import (
"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
"github.com/gin-gonic/gin"
+ "github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/treenode"
@@ -701,7 +702,13 @@ func updateBlock(c *gin.Context) {
tree.Root.FirstChild.Unlink() // 删除列表
tree.Root.FirstChild.Unlink() // 继续删除列表 IAL
}
- tree.Root.FirstChild.SetIALAttr("id", id)
+
+ if nil != tree.Root.FirstChild {
+ tree.Root.FirstChild.SetIALAttr("id", id)
+ } else {
+ logging.LogWarnf("tree root has no child node when updating block [id=%s]", id)
+ return
+ }
data = luteEngine.Tree2BlockDOM(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)
transactions = []*model.Transaction{