siyuan-note/siyuan · error

attribute view rich text tree is missing

Error message

attribute view rich text tree is missing

What it means

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.

Solutions

  1. Check and propagate the error from the parse step before calling RenderTableCellRich / validation, so nil trees never reach the validator
  2. Ensure the content parsed successfully (non-empty valid kramdown) so lute produces a rooted tree
  3. If calling validateValueTextRichTree directly, guard: if tree == nil || tree.Root == nil, skip or return early
  4. Upgrade the kernel version if your data comes from an older lute that could return nil trees

Example fix

// before
tree, _ := av.ParseValueTextRich(rich)
err := validateValueTextRichTree(tree) // nil tree when parse failed
// after
tree, err := av.ParseValueTextRich(rich)
if err != nil { return err }
err = validateValueTextRichTree(tree)
Defensive patterns

Strategy: type-guard

Validate before calling

if tree == nil || tree.Root == nil { return errors.New("no tree to validate; parse must have failed") }

Type guard

func hasRoot(t *parse.Tree) bool { return t != nil && t.Root != nil }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/c84da79ce9d89838. Report an issue: GitHub.

Appendix: source

Thrown at kernel/av/value.go:600

		return
	}
	if 0 < len(protectedStyleEntities) {
		if err = restoreValueTextRichTreeStyleEntities(tree, protectedStyleEntities); nil != err {
			return
		}
		blockDOM = luteEngine.Tree2BlockDOM(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)
	}
	err = validateValueTextRichTreeWithImages(tree, images)
	return
}

func validateValueTextRichTree(tree *parse.Tree) (err error) {
	return validateValueTextRichTreeWithImages(tree, false)
}

func validateValueTextRichTreeWithImages(tree *parse.Tree, images bool) (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) && !(images && isAllowedTableCellRichImageNode(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 9f775e8a12)