siyuan-note/siyuan · error
new item template [ ] not found
Error message
new item template [%s] not found
What it means
createAttributeViewItem resolves an optional templateID against the attribute view's registered new-item templates. If a non-empty templateID is supplied but no template with that ID exists, the creation is aborted with this formatted error naming the missing template ID.
Solutions
- Fetch the attribute view's new-item templates (e.g. GetNewItemTemplate options) and use a valid templateID
- Omit templateID (empty string) to create a default detached item
- Re-list templates at call time instead of using a cached ID
Example fix
// before
res, err := CreateAttributeViewItem(avID, blockID, viewID, "tpl-gone", prevID, groupID)
// after
tplID := ""
if attrView.GetNewItemTemplate("tpl-gone") != nil {
tplID = "tpl-gone"
}
res, err := CreateAttributeViewItem(avID, blockID, viewID, tplID, prevID, groupID) Defensive patterns
Strategy: try-catch
Validate before calling
const av = await api.getAttributeView(avID); const tplExists = !templateID || (av.newItemTemplates||[]).some(t => t.id === templateID); if (!tplExists) templateID = ''; // fall back to default detached item
Try / catch
try {
return await api.createAttributeViewItem({avID, blockID, templateID});
} catch (e) {
if (e.message.includes('not found') && e.message.includes('template')) {
return await api.createAttributeViewItem({avID, blockID, templateID: ''});
}
} Prevention
- Resolve template IDs from the view's current template list, not cache
- Pass empty templateID for default item creation
- Re-fetch templates after any view reconfiguration
When it happens
Trigger: Calling CreateAttributeViewItem or CreateAttributeViewItemWithMarkdown with a templateID that is not registered in the attribute view's new-item templates (empty templateID is allowed and falls back to the detached default).
Common situations: Stale template IDs after a template was deleted or the view was reconfigured; template IDs copied from another attribute view; plugin clients caching template IDs across view edits.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- attribute view [ ] not found in box [ ]
- attribute view [ ] view [ ] not found
- attribute view [ ] visible view [ ] not found
- attribute view not found
- attribute view [ ] has no available view
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/72e8a79e5dfe84e1.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/attribute_view_new_item.go:104
func CreateAttributeViewItemWithMarkdown(avID, blockID, viewID, templateID, previousID, groupID string,
document *CreateAttributeViewItemMarkdown) (*CreateAttributeViewItemResult, error) {
if nil == document {
return nil, errors.New("attribute view item markdown is nil")
}
return createAttributeViewItem(avID, blockID, viewID, templateID, previousID, groupID, document)
}
func createAttributeViewItem(avID, blockID, viewID, templateID, previousID, groupID string,
document *CreateAttributeViewItemMarkdown) (*CreateAttributeViewItemResult, error) {
attrView, err := avParseView(avID, blockID)
if nil != err {
return nil, err
}
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.TitleView on GitHub (pinned to 9f775e8a12)