From 89dc302694ea1308cd974cccfdefcbf4c7ee2e45 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 26 Dec 2025 21:58:49 +0800 Subject: [PATCH] :bug: The `updateBlock` API encountered a null pointer error https://github.com/siyuan-note/siyuan/issues/16705 Signed-off-by: Daniel <845765@qq.com> --- kernel/api/block_op.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/api/block_op.go b/kernel/api/block_op.go index 31b5567a8..1d58fb9af 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{