{"record":{"id":"9230cb488be08100","repo":"siyuan-note/siyuan","slug":"database-blocks-are-not-supported-by-createdoctree-9230cb","errorCode":null,"errorMessage":"database blocks are not supported by createDocTree templates","messagePattern":"database blocks are not supported by createDocTree templates","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_doc_tree_render.go","lineNumber":264,"sourceCode":"\tcontains := false\n\tast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {\n\t\tif entering && ast.NodeAttributeView == node.Type {\n\t\t\tcontains = true\n\t\t\treturn ast.WalkStop\n\t\t}\n\t\treturn ast.WalkContinue\n\t})\n\treturn contains\n}\n\nfunc renderTemplateDocTreeMarkdown(markdown []byte, boxID string) (*parse.Tree, error) {\n\ttree, err := parseTemplateKTree(markdown)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttree.Box = boxID\n\tif templateTreeContainsAttributeView(tree) {\n\t\treturn nil, errors.New(\"database blocks are not supported by createDocTree templates\")\n\t}\n\n\tvar nodesNeedAppendChild, unlinks []*ast.Node\n\tblockIDs := map[string]string{}\n\tast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {\n\t\tif !entering {\n\t\t\treturn ast.WalkContinue\n\t\t}\n\n\t\tif \"\" != node.ID {\n\t\t\toldID := node.ID\n\t\t\tnode.ID = ast.NewNodeID()\n\t\t\tblockIDs[oldID] = node.ID\n\t\t\tnode.SetIALAttr(\"id\", node.ID)\n\t\t\tnode.RemoveIALAttr(av.NodeAttrNameAvs)\n\t\t\ttreenode.RefreshUpdated(node)\n\t\t}\n\t\tif (ast.NodeListItem == node.Type && (nil == node.FirstChild ||","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template_doc_tree_render.go#L246-L282","documentation":"createDocTree-style template rendering refuses to process a template whose parsed tree contains an attribute view (database) block. Database blocks have no plain-markdown rendering semantics in this code path, so rendering is aborted instead of producing a silently incomplete document tree. The check runs after parsing the template markdown via parseTemplateKTree and before walking nodes.","triggerScenarios":"renderTemplateDocTreeMarkdown is called with markdown containing a database/attribute-view block (e.g. a template saved from a document that embeds an attribute view); templateTreeContainsAttributeView returns true and the error is returned to the createDocTree template renderer.","commonSituations":"Users save a document that contains a database block as a template and then use it in a createDocTree flow; templates copied from other documents with embedded databases; older templates that gained database blocks after an upgrade.","solutions":["Remove the database/attribute-view block from the template markdown before rendering","Use a template without database blocks for createDocTree rendering","Render through a path that supports database blocks instead of the createDocTree template renderer"],"exampleFix":"// before: template.md contains a database block -> render fails\n// after: strip the database block\nmarkdown = removeDatabaseBlocks(markdown)\ntree, err := renderTemplateDocTreeMarkdown(markdown, boxID, ...)\n","handlingStrategy":"validation","validationCode":"func hasDatabaseBlock(markdown []byte) bool {\n    engine := model.NewLute()\n    tree := parse.Parse(\"\", markdown, engine.ParseOptions)\n    return tree != nil && model.TemplateTreeContainsAttributeView(tree)\n}\n// call renderTemplateDocTreeMarkdown only if !hasDatabaseBlock(md)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep createDocTree templates free of database/attribute-view blocks","Check templates with templateTreeContainsAttributeView before rendering","Regenerate templates from documents without embedded databases"],"tags":["template","database-block","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}