siyuan-note/siyuan · error
attribute view rich text tree is missing
Error message
attribute view rich text tree is missing
What it means
validateValueTextRichTree guards the DOM tree produced from rich-text content: a nil tree or nil root is reported as "attribute view rich text tree is missing". It is the entry-point check of the tree validator used by parseValueTextRich and RenderValueTextRich before walking nodes.
Source
Thrown at kernel/av/value.go:592
}
blockDOM, tree = luteEngine.Md2BlockDOMTree(content, true)
if nil == tree || nil == tree.Root {
err = fmt.Errorf("parse attribute view rich text failed")
return
}
if 0 < len(protectedStyleEntities) {
if err = restoreValueTextRichTreeStyleEntities(tree, protectedStyleEntities); nil != err {
return
}
blockDOM = luteEngine.Tree2BlockDOM(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)
}
err = validateValueTextRichTree(tree)
return
}
func validateValueTextRichTree(tree *parse.Tree) (err error) {
if nil == tree || nil == tree.Root {
return fmt.Errorf("attribute view rich text tree is missing")
}
ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
if !isAllowedValueTextRichNode(node) {
err = fmt.Errorf("unsupported attribute view rich text node [%s]", node.Type.String())
return ast.WalkStop
}
return ast.WalkContinue
})
return
}
// newValueTextRichLute 固定启用存储格式支持的语法,避免编辑器开关变化后重解释既有数据。
func newValueTextRichLute() *lute.Lute {
ret := lute.New()
ret.SetTextMark(true)View on GitHub (pinned to 8641553a1f)
Solutions
- Ensure the tree comes from parseValueTextRich (or Md2BlockDOMTree) rather than being constructed ad hoc
- Check for and handle the parse error from ParseValueTextRich before calling RenderValueTextRich
- Initialize the tree properly in tests/plugin code before validation
- Fix the underlying content issue (see error 235) so parsing yields a real root
Example fix
// before var tree *parse.Tree err = validateValueTextRichTree(tree) // nil tree // after tree := luteEngine.Md2BlockDOMTree(content, true) err = validateValueTextRichTree(tree)
Defensive patterns
Strategy: type-guard
Validate before calling
if tree == nil || tree.Root == nil { return errors.New("tree not parsed") } Type guard
func hasRoot(tree *parse.Tree) bool { return tree != nil && tree.Root != nil } Try / catch
if err := av.RenderValueTextRich(tree); err != nil { /* handle missing-tree case */ } Prevention
- Always derive trees from ParseValueTextRich, never construct by hand
- Check the parse error before using the returned tree
- Initialize test fixtures with real parsed trees
When it happens
Trigger: RenderValueTextRich called with a nil tree argument, or parseValueTextRich somehow proceeding with a degenerate parse result (nil tree/root). Callers pass a parse.Tree that failed to materialize.
Common situations: Plugin code calling RenderValueTextRich directly with an uninitialized tree; callers skipping parseValueTextRich's earlier nil-tree error path; mocked trees in tests left nil.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- encoded style entity is not attached to an attribute view ri
- invalid encoded style entity in attribute view rich text spa
- invalid encoded style entity in attribute view rich text mar
- invalid encoded style entity in attribute view rich text nod
- wrong layout type
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/c84da79ce9d89838.
Report an issue: GitHub.