siyuan-note/siyuan · error
attribute view [ ] has no available view
Error message
attribute view [%s] has no available view: %w
What it means
When the template's attribute-view node specifies no view ID, validateTemplateAttributeViewNode falls back to attrView.GetFirstView(). If that also fails (the attribute view has no views at all), the underlying error is wrapped as 'attribute view [%s] has no available view'. Template rendering is aborted because there is nothing to render for the database block.
Solutions
- Open the attribute view in the SiYuan UI and add at least one view (e.g. a table view)
- Restore the database file from backup/sync history if views were lost to corruption
- Re-point the template's database block at a healthy attribute view
- Recreate the database and regenerate the template
Defensive patterns
Strategy: validation
Validate before calling
const av = await getAttrView(avID);
if (!av.views || av.views.length === 0) {
await createAttrViewView(avID, "Table"); // ensure at least one view
} Try / catch
try {
await insertTemplate(path);
} catch (e) {
if (String(e).includes("has no available view")) {
await repairAttrViewViews(avID); // restore from backup or add a view
}
} Prevention
- Keep at least one view in every database referenced by templates
- Back up storage/av/ before editing database files externally
- Restore databases from sync history after corruption instead of editing JSON by hand
When it happens
Trigger: Rendering a template whose attribute-view node lacks `custom-av-view` while the referenced attribute view has zero views (e.g. a corrupted or manually truncated .av JSON where the Views array is empty), so GetFirstView errors and gets wrapped here.
Common situations: Databases damaged by partial writes, external edits to storage/av/*.json that emptied the views list, or templates copied from a source database that lost its views.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- attribute view [ ] has no available visible view
- attribute view [ ] not found in box [ ]
- attribute view [ ] template plan not found
- attribute view [ ] view [ ] not found
- attribute view [ ] visible view [ ] not found
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/b66109ed3ed2db89.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template.go:582
if "" == value {
return TemplateDatabaseModeCopy, nil
}
ret = TemplateDatabaseMode(value)
if TemplateDatabaseModeCopy != ret && TemplateDatabaseModeReference != ret {
return "", fmt.Errorf("unsupported template database mode [%s]", value)
}
return
}
func validateTemplateAttributeViewNode(node *ast.Node, attrView *av.AttributeView) (selectedView *av.View, err error) {
viewID := strings.TrimSpace(node.IALAttr(av.NodeAttrView))
if "" != viewID {
selectedView = attrView.GetView(viewID)
if nil == selectedView {
return nil, fmt.Errorf("attribute view [%s] view [%s] not found", attrView.ID, viewID)
}
} else if selectedView, err = attrView.GetFirstView(); nil != err {
return nil, fmt.Errorf("attribute view [%s] has no available view: %w", attrView.ID, err)
}
visibleViewIDs := strings.TrimSpace(node.IALAttr(av.NodeAttrVisibleViewIDs))
if "" == visibleViewIDs {
return
}
visibleViewCount := 0
for _, visibleViewID := range strings.Split(visibleViewIDs, ",") {
visibleViewID = strings.TrimSpace(visibleViewID)
if "" == visibleViewID {
continue
}
visibleViewCount++
if nil == attrView.GetView(visibleViewID) {
return nil, fmt.Errorf("attribute view [%s] visible view [%s] not found", attrView.ID, visibleViewID)
}
}
if 1 > visibleViewCount {View on GitHub (pinned to 9f775e8a12)