{"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":498,"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":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template.go#L480-L516","documentation":"When a template database node has no explicit view IAL, validateTemplateAttributeViewNode falls back to attrView.GetFirstView(). If that fails — the attribute view has no views at all — this wrapped error reports the attribute view ID with the underlying cause via %w.","triggerScenarios":"A template contains a database block whose attribute view exists but contains zero views, or GetFirstView returns an error because the view list is empty or corrupt.","commonSituations":"Hand-crafted templates with an empty av JSON, databases corrupted by failed sync, or templates referencing a deleted database.","solutions":["Open the source document and confirm the database still has at least one view; recreate one if it was deleted","Remove the broken database block from the template","Restore the database from snapshot/history or a sync backup"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if views := attrView.Views; len(views) == 0 {\n    return errors.New('attribute view has no views') // strip or skip this node before template use\n}","typeGuard":"func hasAnyView(attrView *av.AttributeView) bool {\n    _, err := attrView.GetFirstView()\n    return err == nil\n}","tryCatchPattern":"selectedView, err := validateTemplateAttributeViewNode(node, attrView)\nif err != nil {\n    if strings.Contains(err.Error(), 'has no available view') {\n        return fmt.Errorf('skipping empty database %s', attrView.ID)\n    }\n    return err\n}","preventionTips":["Never ship templates with databases that have zero views","Verify databases after restoring from sync or history before saving as a template","Add at least one view to any database included in a template"],"tags":["go","attribute-view","template","corruption"],"backgroundTag":"empty-result-set","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}