{"record":{"id":"b66109ed3ed2db89","repo":"siyuan-note/siyuan","slug":"attribute-view-s-has-no-available-view-w","errorCode":null,"errorMessage":"attribute view [%s] has no available view: %w","messagePattern":"attribute view \\[(.+?)\\] has no available view: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template.go","lineNumber":582,"sourceCode":"\tif \"\" == value {\n\t\treturn TemplateDatabaseModeCopy, nil\n\t}\n\tret = TemplateDatabaseMode(value)\n\tif TemplateDatabaseModeCopy != ret && TemplateDatabaseModeReference != ret {\n\t\treturn \"\", fmt.Errorf(\"unsupported template database mode [%s]\", value)\n\t}\n\treturn\n}\n\nfunc validateTemplateAttributeViewNode(node *ast.Node, attrView *av.AttributeView) (selectedView *av.View, err error) {\n\tviewID := strings.TrimSpace(node.IALAttr(av.NodeAttrView))\n\tif \"\" != viewID {\n\t\tselectedView = attrView.GetView(viewID)\n\t\tif nil == selectedView {\n\t\t\treturn nil, fmt.Errorf(\"attribute view [%s] view [%s] not found\", attrView.ID, viewID)\n\t\t}\n\t} else if selectedView, err = attrView.GetFirstView(); nil != err {\n\t\treturn nil, fmt.Errorf(\"attribute view [%s] has no available view: %w\", attrView.ID, err)\n\t}\n\n\tvisibleViewIDs := strings.TrimSpace(node.IALAttr(av.NodeAttrVisibleViewIDs))\n\tif \"\" == visibleViewIDs {\n\t\treturn\n\t}\n\tvisibleViewCount := 0\n\tfor _, visibleViewID := range strings.Split(visibleViewIDs, \",\") {\n\t\tvisibleViewID = strings.TrimSpace(visibleViewID)\n\t\tif \"\" == visibleViewID {\n\t\t\tcontinue\n\t\t}\n\t\tvisibleViewCount++\n\t\tif nil == attrView.GetView(visibleViewID) {\n\t\t\treturn nil, fmt.Errorf(\"attribute view [%s] visible view [%s] not found\", attrView.ID, visibleViewID)\n\t\t}\n\t}\n\tif 1 > visibleViewCount {","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template.go#L564-L600","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const av = await getAttrView(avID);\nif (!av.views || av.views.length === 0) {\n  await createAttrViewView(avID, \"Table\"); // ensure at least one view\n}","typeGuard":null,"tryCatchPattern":"try {\n  await insertTemplate(path);\n} catch (e) {\n  if (String(e).includes(\"has no available view\")) {\n    await repairAttrViewViews(avID); // restore from backup or add a view\n  }\n}","preventionTips":["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"],"tags":["attribute-view","template","empty"],"backgroundTag":"empty-result-set","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"}