Skip to content

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

:bug: Fix NPE https://github.com/siyuan-note/siyuan/issues/11497

Daniel98e808312239
diff --git a/kernel/model/render.go b/kernel/model/render.go
index 8eed06c531..b6c73080cd 100644
--- a/kernel/model/render.go
+++ b/kernel/model/render.go
@@ -93,6 +93,10 @@ func renderOutline(heading *ast.Node, luteEngine *lute.Lute) (ret string) {
}
func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {
+ if nil == node {
+ return
+ }
+
ret = sql.NodeStaticContent(node, excludeTypes, false, false, false, GetBlockAttrsWithoutWaitWriting)
ret = strings.TrimSpace(ret)
ret = strings.ReplaceAll(ret, "\n", "")
diff --git a/kernel/sql/block.go b/kernel/sql/block.go
index 192d373f7d..0c98a22a7f 100644
--- a/kernel/sql/block.go
+++ b/kernel/sql/block.go
@@ -139,6 +139,10 @@ func indexNode(tx *sql.Tx, id string) (err error) {
func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL, includeAssetPath, fullAttrView bool,
GetBlockAttrsWithoutWaitWriting func(id string) (ret map[string]string)) string {
+ if nil == node {
+ return ""
+ }
+
if ast.NodeAttributeView == node.Type {
if fullAttrView {
return getAttributeViewContent(node.AttributeViewID, GetBlockAttrsWithoutWaitWriting)
diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go
index f0176df3fd..d723ff71e9 100644
--- a/kernel/sql/block_query.go
+++ b/kernel/sql/block_query.go
@@ -812,6 +812,10 @@ func GetContainerText(container *ast.Node) string {
buf := &bytes.Buffer{}
buf.Grow(4096)
leaf := treenode.FirstLeafBlock(container)
+ if nil == leaf {
+ return ""
+ }
+
ast.Walk(leaf, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue