Skip to content

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

:bug: Fix NPE

Daniel973f99b690a0
diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go
index 2fbb899c20..9ab52c9602 100644
--- a/kernel/model/backlink.go
+++ b/kernel/model/backlink.go
@@ -483,6 +483,10 @@ func GetBacklink(id, keyword, mentionKeyword string, beforeLen int, containChild
}
paragraphParents := sql.GetBlocks(paragraphParentIDs)
for _, p := range paragraphParents {
+ if nil == p {
+ continue
+ }
+
if "i" == p.Type || "h" == p.Type {
linkRefs = append(linkRefs, fromSQLBlock(p, keyword, beforeLen))
processedParagraphs.Add(p.ID)
@@ -589,6 +593,10 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret []
originalRefBlockIDs = map[string]string{}
processedParagraphs := hashset.New()
for _, parent := range paragraphParents {
+ if nil == parent {
+ continue
+ }
+
if "NodeListItem" == parent.Type || "NodeBlockquote" == parent.Type || "NodeSuperBlock" == parent.Type {
refBlock := parentRefParagraphs[parent.ID]
if nil == refBlock {
diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.go
index d739d42ad4..c68ef1717d 100644
--- a/kernel/model/blockinfo.go
+++ b/kernel/model/blockinfo.go
@@ -624,6 +624,10 @@ func buildBacklinkListItemRefs(refDefs []*RefDefs) (originalRefBlockIDs map[stri
luteEngine := util.NewLute()
processedParagraphs := hashset.New()
for _, parent := range paragraphParents {
+ if nil == parent {
+ continue
+ }
+
if "NodeListItem" == parent.Type || "NodeBlockquote" == parent.Type || "NodeSuperBlock" == parent.Type {
refBlock := parentRefParagraphs[parent.ID]
if nil == refBlock {