An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Fix nil pointer when AV block key values or block object is missing https://ld246.com/article/1779156833356 (#17719)
Jeffrey Chen04e808208425
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 2bda90b6aa..5913838630 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -3275,31 +3275,36 @@ func getAvNames(avIDs string) (ret string) {func (tx *Transaction) getAttrViewBoundNodes(attrView *av.AttributeView) (trees map[string]*parse.Tree, nodes []*ast.Node) {blockKeyValues := attrView.GetBlockKeyValues()- if nil == blockKeyValues.Values {+ if nil == blockKeyValues || nil == blockKeyValues.Values {return}trees = map[string]*parse.Tree{}for _, blockKeyValue := range blockKeyValues.Values {- if blockKeyValue.IsDetached {+ if blockKeyValue.IsDetached || nil == blockKeyValue.Block {+ continue+ }++ blockID := blockKeyValue.Block.ID+ if "" == blockID {continue}var tree *parse.Tree- tree = trees[blockKeyValue.Block.ID]+ tree = trees[blockID]if nil == tree {if nil == tx {- tree, _ = LoadTreeByBlockID(blockKeyValue.Block.ID)+ tree, _ = LoadTreeByBlockID(blockID)} else {- tree, _ = tx.loadTree(blockKeyValue.Block.ID)+ tree, _ = tx.loadTree(blockID)}}if nil == tree {continue}- trees[blockKeyValue.Block.ID] = tree+ trees[blockID] = tree- node := treenode.GetNodeInTree(tree, blockKeyValue.Block.ID)+ node := treenode.GetNodeInTree(tree, blockID)if nil == node {continue}@@ -5799,11 +5804,21 @@ func updateBoundBlockAvsAttribute(avIDs []string) {}blockKeyValues := attrView.GetBlockKeyValues()+ if nil == blockKeyValues || nil == blockKeyValues.Values {+ continue+ }+for _, blockValue := range blockKeyValues.Values {- if blockValue.IsDetached {+ if blockValue.IsDetached || nil == blockValue.Block {continue}- bt := treenode.GetBlockTree(blockValue.BlockID)++ boundBlockID := blockValue.Block.ID+ if "" == boundBlockID {+ continue+ }++ bt := treenode.GetBlockTree(boundBlockID)if nil == bt {continue}@@ -5817,7 +5832,7 @@ func updateBoundBlockAvsAttribute(avIDs []string) {cachedTrees[bt.RootID] = tree}- node := treenode.GetNodeInTree(tree, blockValue.BlockID)+ node := treenode.GetNodeInTree(tree, boundBlockID)if nil == node {continue}diff --git a/kernel/model/export.go b/kernel/model/export.goindex 55a43a698d..8a6219009d 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -3667,16 +3667,21 @@ func exportRefTrees(tree *parse.Tree, defBlockIDs *[]string, retTrees map[string}blockKeyValues := attrView.GetBlockKeyValues()- if nil == blockKeyValues {+ if nil == blockKeyValues || nil == blockKeyValues.Values {return ast.WalkContinue}for _, val := range blockKeyValues.Values {- if val.IsDetached {+ if val.IsDetached || nil == val.Block {continue}- defBlock := treenode.GetBlockTree(val.Block.ID)+ blockID := val.Block.ID+ if "" == blockID {+ continue+ }++ defBlock := treenode.GetBlockTree(blockID)if nil == defBlock {continue}