siyuan-note/siyuan · error

new item template [%s] does not create a bound block

Error message

new item template [%s] does not create a bound block

What it means

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.

Source

Thrown at kernel/model/attribute_view_new_item.go:118

	createdAt := time.Now()
	itemTemplate := attrView.GetNewItemTemplate(templateID)
	var prunedOptions []*av.PrunedNewItemTemplateOption
	if "" != templateID && nil == itemTemplate {
		return nil, fmt.Errorf("new item template [%s] not found", templateID)
	}
	if nil == itemTemplate {
		itemTemplate = &av.NewItemTemplate{TargetType: av.NewItemTargetDetached}
	} else {
		cloned := *attrView
		prunedOptions = cloned.PruneInvalidNewItemTemplateFieldValues()
		if err = cloned.SetNewItemTemplates(&av.NewItemTemplatesConfig{Templates: []*av.NewItemTemplate{itemTemplate}}); nil != err {
			return nil, err
		}
		attrView = &cloned
		itemTemplate = cloned.NewItemTemplates[0]
	}
	if nil != document && av.NewItemTargetDocument != itemTemplate.TargetType {
		return nil, fmt.Errorf("new item template [%s] does not create a bound block", templateID)
	}
	primaryFallback := ""
	if nil != document {
		primaryFallback = document.Title
	}
	preview, err := resolveAttributeViewNewItemTemplateWithFallback(blockID, itemTemplate, createdAt, primaryFallback)
	if nil != err {
		return nil, err
	}
	for _, prunedOption := range prunedOptions {
		if templateID == prunedOption.TemplateID {
			preview.Warnings = append(preview.Warnings, fmt.Sprintf(Conf.Language(353),
				prunedOption.KeyID, strings.Join(prunedOption.Values, ", ")))
		}
	}

	dbTree, err := LoadTreeByBlockID(blockID)
	if nil != err {

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Use a template with TargetType document when passing a Markdown document
  2. Drop the document parameter (use CreateAttributeViewItem) if a detached/non-document template is intended
  3. Check itemTemplate.TargetType in the caller before choosing which create function to use

Example fix

// before
res, err := model.CreateAttributeViewItemWithMarkdown(avID, blockID, viewID, detachedTplID, "", "", doc)
// after
if itemTemplate.TargetType == av.NewItemTargetDocument {
    res, err = model.CreateAttributeViewItemWithMarkdown(avID, blockID, viewID, detachedTplID, "", "", doc)
} else {
    res, err = model.CreateAttributeViewItem(avID, blockID, viewID, detachedTplID, "", "")
}
Defensive patterns

Strategy: validation

Validate before calling

if document != nil && itemTemplate != nil && itemTemplate.TargetType != av.NewItemTargetDocument {
    return errors.New("markdown payload requires a document-creating template")
}

Try / catch

res, err := model.CreateAttributeViewItemWithMarkdown(...)
if err != nil && strings.Contains(err.Error(), "does not create a bound block") {
    // retry with CreateAttributeViewItem (no document) or a document-type template
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/1eec4a644b5ef160. Report an issue: GitHub.