{"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":"exception","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\trestoreTabsSelection := captureTemplateTabsSelection(tree.Root)\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}","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template_doc_tree_render.go#L246-L282","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Remove the database (attribute view) block from the template source","Replace the database with a static table or list describing the same content","If a database is required, create the doc normally and add the attribute view manually after generation","Search the template markdown for the database block syntax and delete that paragraph"],"exampleFix":"// before (template markdown)\n{{SELECT * FROM blocks ...}}\n// after: remove the database block, use a markdown table\n| col |\n| --- |","handlingStrategy":"validation","validationCode":"// before using a template with createDocTree, grep its markdown for database block syntax\nif strings.Contains(md, \"{{SELECT\") { /* reject */ }","typeGuard":null,"tryCatchPattern":"if err != nil { return fmt.Errorf(\"createDocTree failed: %w\", err) }","preventionTips":["Never copy database blocks into createDocTree templates","Represent tabular data with static markdown tables in templates","Add attribute views to generated documents after creation, not from the template"],"tags":["template","attribute-view","database","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}