{"record":{"id":"1eec4a644b5ef160","repo":"siyuan-note/siyuan","slug":"new-item-template-s-does-not-create-a-bound-blo","errorCode":null,"errorMessage":"new item template [%s] does not create a bound block","messagePattern":"new item template \\[(.+?)\\] does not create a bound block","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_new_item.go","lineNumber":118,"sourceCode":"\tcreatedAt := time.Now()\n\titemTemplate := attrView.GetNewItemTemplate(templateID)\n\tvar prunedOptions []*av.PrunedNewItemTemplateOption\n\tif \"\" != templateID && nil == itemTemplate {\n\t\treturn nil, fmt.Errorf(\"new item template [%s] not found\", templateID)\n\t}\n\tif nil == itemTemplate {\n\t\titemTemplate = &av.NewItemTemplate{TargetType: av.NewItemTargetDetached}\n\t} else {\n\t\tcloned := *attrView\n\t\tprunedOptions = cloned.PruneInvalidNewItemTemplateFieldValues()\n\t\tif err = cloned.SetNewItemTemplates(&av.NewItemTemplatesConfig{Templates: []*av.NewItemTemplate{itemTemplate}}); nil != err {\n\t\t\treturn nil, err\n\t\t}\n\t\tattrView = &cloned\n\t\titemTemplate = cloned.NewItemTemplates[0]\n\t}\n\tif nil != document && av.NewItemTargetDocument != itemTemplate.TargetType {\n\t\treturn nil, fmt.Errorf(\"new item template [%s] does not create a bound block\", templateID)\n\t}\n\tprimaryFallback := \"\"\n\tif nil != document {\n\t\tprimaryFallback = document.Title\n\t}\n\tpreview, err := resolveAttributeViewNewItemTemplateWithFallback(blockID, itemTemplate, createdAt, primaryFallback)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\tfor _, prunedOption := range prunedOptions {\n\t\tif templateID == prunedOption.TemplateID {\n\t\t\tpreview.Warnings = append(preview.Warnings, fmt.Sprintf(Conf.Language(353),\n\t\t\t\tprunedOption.KeyID, strings.Join(prunedOption.Values, \", \")))\n\t\t}\n\t}\n\n\tdbTree, err := LoadTreeByBlockID(blockID)\n\tif nil != err {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/attribute_view_new_item.go#L100-L136","documentation":"A Markdown-based item (document != nil) can only be used with a template whose TargetType is NewItemTargetDocument, because binding a document requires the template to actually create one. If the chosen template creates a detached row or another target, passing a Markdown document is contradictory and rejected.","triggerScenarios":"Calling CreateAttributeViewItemWithMarkdown (or CreateAttributeViewItem with a document) with a templateID pointing at a template whose TargetType is not \"document\" — e.g. a detached-row template.","commonSituations":"A plugin that lets the user pick any new-item template but always attaches Markdown content; a template reconfigured from document to detached after the caller captured its ID; confusing CreateAttributeViewItem with the Markdown variant.","solutions":["Use a template with TargetType document when passing a Markdown document","Drop the document parameter (use CreateAttributeViewItem) if a detached/non-document template is intended","Check itemTemplate.TargetType in the caller before choosing which create function to use"],"exampleFix":"// before\nres, err := model.CreateAttributeViewItemWithMarkdown(avID, blockID, viewID, detachedTplID, \"\", \"\", doc)\n// after\nif itemTemplate.TargetType == av.NewItemTargetDocument {\n    res, err = model.CreateAttributeViewItemWithMarkdown(avID, blockID, viewID, detachedTplID, \"\", \"\", doc)\n} else {\n    res, err = model.CreateAttributeViewItem(avID, blockID, viewID, detachedTplID, \"\", \"\")\n}","handlingStrategy":"validation","validationCode":"if document != nil && itemTemplate != nil && itemTemplate.TargetType != av.NewItemTargetDocument {\n    return errors.New(\"markdown payload requires a document-creating template\")\n}","typeGuard":null,"tryCatchPattern":"res, err := model.CreateAttributeViewItemWithMarkdown(...)\nif err != nil && strings.Contains(err.Error(), \"does not create a bound block\") {\n    // retry with CreateAttributeViewItem (no document) or a document-type template\n}","preventionTips":["Check the template's TargetType before deciding to attach Markdown content","Keep template type and creation call in sync when templates are reconfigured","Prefer CreateAttributeViewItem for detached-row templates"],"tags":["api","template","attribute-view","incompatible"],"backgroundTag":"incompatible-source-type","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"}