siyuan-note/siyuan · error

attribute view [ ] template plan not found

Error message

attribute view [%s] template plan not found

What it means

During the apply phase of template rendering, every attribute view node in the parsed tree must have a matching plan prepared in the earlier planning walk. If attributeViewPlans has no entry for a node, the tree and plan phase are inconsistent and the walk stops with this error naming the node's AttributeViewID. This is an internal invariant: planTemplateAttributeViews should have registered a plan (even a degenerate one) for every av node.

Solutions

  1. Re-run the render; if transient it indicates a race between planning and applying.
  2. Verify the attribute view ID on the offending block matches a real block in the template source.
  3. If reproducible, file a bug with the template: this signals the planner skipped the node (check templateAttributeViewMode validation and earlier error paths that returned WalkStop).
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil && strings.Contains(err.Error(), "template plan not found") {
    // planner/apply mismatch; re-render once before surfacing
    return renderTemplateWithMode(id, mode)
}

Prevention

When it happens

Trigger: rendering a tree where an ast.NodeAttributeView was not visited (or a different tree instance's node map) during planning — e.g. nodes injected after planning, walking a different root, or plan map keyed by node pointers that no longer match after tree mutation.

Common situations: Kernel bug or regression after tree rewriting between plan and apply; custom code paths that modify the parsed tree between the two walks; node identity changed because the tree was re-parsed.

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


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

Appendix: source

Thrown at kernel/model/template.go:985

		if (ast.NodeListItem == n.Type && (nil == n.FirstChild ||
			(3 == n.ListData.Typ && (nil == n.FirstChild.Next || ast.NodeKramdownBlockIAL == n.FirstChild.Next.Type)))) ||
			(ast.NodeBlockquote == n.Type && nil != n.FirstChild && nil != n.FirstChild.Next && ast.NodeKramdownBlockIAL == n.FirstChild.Next.Type) ||
			(ast.NodeCallout == n.Type && nil != n.FirstChild && ast.NodeKramdownBlockIAL == n.FirstChild.Type) {
			nodesNeedAppendChild = append(nodesNeedAppendChild, n)
		}

		if n.IsTextMarkType("inline-math") {
			if n.ParentIs(ast.NodeTableCell) {
				// 表格中的公式中带有管道符时使用 HTML 实体替换管道符 Improve the handling of inline-math containing `|` in the table https://github.com/siyuan-note/siyuan/issues/9227
				n.TextMarkInlineMathContent = strings.ReplaceAll(n.TextMarkInlineMathContent, "|", "|")
			}
		}

		if ast.NodeAttributeView == n.Type {
			plan := attributeViewPlans[n]
			if nil == plan {
				err = fmt.Errorf("attribute view [%s] template plan not found", n.AttributeViewID)
				return ast.WalkStop
			}
			appliedView, applyErr := applyTemplateAttributeViewPlan(n, plan)
			if nil != applyErr {
				err = applyErr
				return ast.WalkStop
			}
			if preview && nil != appliedView {
				templateAttributeViewPreviewTable(n, plan)
				unlinks = append(unlinks, n)
			}
		}

		return ast.WalkContinue
	})
	if nil != err {
		return
	}

View on GitHub (pinned to 9f775e8a12)