siyuan-note/siyuan · error

database blocks are not supported by createDocTree templates

Error message

database blocks are not supported by createDocTree templates

What it means

renderTemplateDocTreeMarkdown explicitly rejects rendered template output that contains a database (attribute view) block. createDocTree generates multiple new documents from a template, and database blocks cannot be safely cloned/rewired across generated documents, so the kernel stops with this sentinel error.

Solutions

  1. Remove the database (attribute view) block from the template source
  2. Replace the database with a static table or list describing the same content
  3. If a database is required, create the doc normally and add the attribute view manually after generation
  4. Search the template markdown for the database block syntax and delete that paragraph

Example fix

// before (template markdown)
{{SELECT * FROM blocks ...}}
// after: remove the database block, use a markdown table
| col |
| --- |
Defensive patterns

Strategy: validation

Validate before calling

// before using a template with createDocTree, grep its markdown for database block syntax
if strings.Contains(md, "{{SELECT") { /* reject */ }

Try / catch

if err != nil { return fmt.Errorf("createDocTree failed: %w", err) }

Prevention

When it happens

Trigger: Raised when the markdown produced by a createDocTree template node parses into a tree where templateTreeContainsAttributeView finds an ast.NodeAttributeView: the template body contains a database block (e.g. pasted from a document containing an attribute view, or a {{.}} expansion that includes one).

Common situations: Authors building a template from an existing document that included a database block, or using template content sourced from a document export that inlined attribute views.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/template_doc_tree_render.go:264

	contains := false
	ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {
		if entering && ast.NodeAttributeView == node.Type {
			contains = true
			return ast.WalkStop
		}
		return ast.WalkContinue
	})
	return contains
}

func renderTemplateDocTreeMarkdown(markdown []byte, boxID string) (*parse.Tree, error) {
	tree, err := parseTemplateKTree(markdown)
	if err != nil {
		return nil, err
	}
	tree.Box = boxID
	if templateTreeContainsAttributeView(tree) {
		return nil, errors.New("database blocks are not supported by createDocTree templates")
	}

	var nodesNeedAppendChild, unlinks []*ast.Node
	blockIDs := map[string]string{}
	restoreTabsSelection := captureTemplateTabsSelection(tree.Root)
	ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {
		if !entering {
			return ast.WalkContinue
		}

		if "" != node.ID {
			oldID := node.ID
			node.ID = ast.NewNodeID()
			blockIDs[oldID] = node.ID
			node.SetIALAttr("id", node.ID)
			node.RemoveIALAttr(av.NodeAttrNameAvs)
			treenode.RefreshUpdated(node)
		}

View on GitHub (pinned to 9f775e8a12)