{"record":{"id":"c84da79ce9d89838","repo":"siyuan-note/siyuan","slug":"attribute-view-rich-text-tree-is-missing","errorCode":null,"errorMessage":"attribute view rich text tree is missing","messagePattern":"attribute view rich text tree is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/value.go","lineNumber":600,"sourceCode":"\t\treturn\n\t}\n\tif 0 < len(protectedStyleEntities) {\n\t\tif err = restoreValueTextRichTreeStyleEntities(tree, protectedStyleEntities); nil != err {\n\t\t\treturn\n\t\t}\n\t\tblockDOM = luteEngine.Tree2BlockDOM(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)\n\t}\n\terr = validateValueTextRichTreeWithImages(tree, images)\n\treturn\n}\n\nfunc validateValueTextRichTree(tree *parse.Tree) (err error) {\n\treturn validateValueTextRichTreeWithImages(tree, false)\n}\n\nfunc validateValueTextRichTreeWithImages(tree *parse.Tree, images bool) (err error) {\n\tif nil == tree || nil == tree.Root {\n\t\treturn fmt.Errorf(\"attribute view rich text tree is missing\")\n\t}\n\tast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {\n\t\tif !entering {\n\t\t\treturn ast.WalkContinue\n\t\t}\n\t\tif !isAllowedValueTextRichNode(node) && !(images && isAllowedTableCellRichImageNode(node)) {\n\t\t\terr = fmt.Errorf(\"unsupported attribute view rich text node [%s]\", node.Type.String())\n\t\t\treturn ast.WalkStop\n\t\t}\n\t\treturn ast.WalkContinue\n\t})\n\treturn\n}\n\n// newValueTextRichLute 固定启用存储格式支持的语法，避免编辑器开关变化后重解释既有数据。\nfunc newValueTextRichLute() *lute.Lute {\n\tret := lute.New()\n\tret.SetTextMark(true)","sourceCodeStart":582,"sourceCodeEnd":618,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/value.go#L582-L618","documentation":"validateValueTextRichTreeWithImages received a nil tree or a tree whose root node is nil, so there is no AST to validate. It is the pre-flight guard for the walker that checks allowed node types; without a root the walk cannot proceed and the rich text is treated as structurally absent.","triggerScenarios":"RenderTableCellRich or parseValueTextRichWithImages receiving a nil *parse.Tree (e.g. parse step already failed and its nil result was passed on), or calling validateValueTextRichTree/validateValueTextRichTreeWithImages directly with nil.","commonSituations":"Chaining parse output into validation without checking the earlier error; a lute parse silently returning nil for degenerate input; tests calling the validator directly with a nil tree.","solutions":["Check and propagate the error from the parse step before calling RenderTableCellRich / validation, so nil trees never reach the validator","Ensure the content parsed successfully (non-empty valid kramdown) so lute produces a rooted tree","If calling validateValueTextRichTree directly, guard: if tree == nil || tree.Root == nil, skip or return early","Upgrade the kernel version if your data comes from an older lute that could return nil trees"],"exampleFix":"// before\ntree, _ := av.ParseValueTextRich(rich)\nerr := validateValueTextRichTree(tree) // nil tree when parse failed\n// after\ntree, err := av.ParseValueTextRich(rich)\nif err != nil { return err }\nerr = validateValueTextRichTree(tree)","handlingStrategy":"type-guard","validationCode":"if tree == nil || tree.Root == nil { return errors.New(\"no tree to validate; parse must have failed\") }","typeGuard":"func hasRoot(t *parse.Tree) bool { return t != nil && t.Root != nil }","tryCatchPattern":null,"preventionTips":["Always check the error from ParseValueTextRich before using the tree","Never pass a parse result with a discarded error into validators","Treat nil-tree as a parse failure, not a validation failure","Assert parse success in tests that feed RenderTableCellRich"],"tags":["attribute-view","rich-text","null-check","ast"],"backgroundTag":"null-argument","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}