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
Templates that call createDocTree generate new documents, and database (attribute view) blocks in such templates are not supported: the kernel rejects the combination explicitly because embedding/copying a database into generated doc trees is undefined in this path.
Solutions
- Remove the database (attribute view) block from the createDocTree template.
- Split into two templates: one that creates the doc tree and one rendered separately that contains the database block.
- Render the database block through a normal document (non-createDocTree) template path.
Example fix
// before (template body)
{{ createDocTree . "root" }}
<div data-type="NodeAttributeView" data-av-id="20240501..."></div>
// after: move the av block out of the createDocTree template
{{ createDocTree . "root" }} Defensive patterns
Strategy: validation
Validate before calling
// pre-check: does the template combine createDocTree with an av block?
if strings.Contains(src, "createDocTree") && strings.Contains(src, "data-av-id") {
return errors.New("remove the database block from createDocTree templates")
} Prevention
- Never embed database blocks in templates that call createDocTree
- Keep doc-tree generation templates free of av embeds
When it happens
Trigger: renderTemplateSource with a template that both uses the createDocTree function (collector has nodes) and whose parsed tree contains an attribute view node (templateTreeContainsAttributeView returns true) — i.e. the template body includes a database block alongside createDocTree calls.
Common situations: A user adds a database embed to a template that also creates a doc tree; a copy-pasted template mixes doc-tree generation with an existing database block; a template evolved over time to include both features.
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
- attribute view [ ] not found in box [ ]
- attribute view [ ] template plan not found
- execute template [ ] failed
- attribute view drop target changed; retry the drag
- attribute view embedded base is missing
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/7c03f1b80e0adccf.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template.go:930
}
if 0 < len(collector.nodes) && maxTemplateDocTreeOutputSize < buf.Len() {
err = fmt.Errorf("template output exceeds %d bytes", maxTemplateDocTreeOutputSize)
return
}
collector.totalOutput = buf.Len()
md = buf.Bytes()
tree, err = parseTemplateKTree(md)
if err != nil {
logging.LogErrorf("parse template [%s] failed: %s", p, err)
return
}
tree.Box = sourceTree.Box
if 0 < len(collector.nodes) {
if err = collector.validateLocations(); nil != err {
return
}
if templateTreeContainsAttributeView(tree) {
err = errors.New("database blocks are not supported by createDocTree templates")
return
}
if err = renderTemplateDocTreeNodes(collector, tpl, tplFuncMap); nil != err {
return
}
}
attributeViewPlans, attributeViewCopies, prepareErr := prepareTemplateAttributeViews(tree, preview)
if nil != prepareErr {
err = prepareErr
return
}
var nodesNeedAppendChild, unlinks []*ast.Node
// 模板内部块旧 ID 到新 ID 的映射,用于成套改写模板内部的自引用
blockIDs := map[string]string{}
restoreTabsSelection := captureTemplateTabsSelection(tree.Root)
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {View on GitHub (pinned to 9f775e8a12)