{"record":{"id":"7c2577ea70fd8e26","repo":"siyuan-note/siyuan","slug":"attribute-view-s-has-no-available-visible-view","errorCode":null,"errorMessage":"attribute view [%s] has no available visible view","messagePattern":"attribute view \\[(.+?)\\] has no available visible view","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template.go","lineNumber":517,"sourceCode":"\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 {\n\t\treturn nil, fmt.Errorf(\"attribute view [%s] has no available visible view\", attrView.ID)\n\t}\n\treturn\n}\n\nfunc resolveCopyTemplateAttributeView(node *ast.Node, attrView *av.AttributeView) *av.View {\n\tif viewID := strings.TrimSpace(node.IALAttr(av.NodeAttrView)); \"\" != viewID {\n\t\tif view := attrView.GetView(viewID); nil != view {\n\t\t\treturn view\n\t\t}\n\t}\n\tview, _ := attrView.GetFirstView()\n\treturn view\n}\n\nfunc copyTemplateAttributeView(source *av.AttributeView) (ret *templateAttributeViewCopy, err error) {\n\ttarget := source.Clone()\n\tif nil == target {\n\t\treturn nil, fmt.Errorf(\"clone attribute view [%s] failed\", source.ID)","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template.go#L499-L535","documentation":"After validating individual entries, validateTemplateAttributeViewNode requires the visible-view-ids attribute to list at least one non-empty view ID. If every entry is empty or whitespace (visibleViewCount == 0), the node would render nothing, so validation aborts with this error.","triggerScenarios":"A template database block has custom-av-visible-view-ids set to an empty string or a list containing only commas/whitespace, leaving no visible views.","commonSituations":"A plugin or script wiping the attribute value, manual editing leaving only separators, or sync conflicts producing an emptied attribute.","solutions":["Set custom-av-visible-view-ids to at least one valid existing view ID","Remove the attribute entirely so the default (first view) applies","Re-save the template through the SiYuan UI to regenerate a correct attribute value"],"exampleFix":"// before (database block IAL in template)\n{: custom-av-visible-view-ids=',,'}\n// after\n{: custom-av-visible-view-ids='20240101120000-abc'}","handlingStrategy":"validation","validationCode":"ids := node.IALAttr('custom-av-visible-view-ids')\nhasAny := false\nfor _, id := range strings.Split(ids, ',') {\n    if strings.TrimSpace(id) != '' {\n        hasAny = true\n        break\n    }\n}\nif ids != '' && !hasAny {\n    node.RemoveIALAttr('custom-av-visible-view-ids') // fall back to defaults\n}","typeGuard":"func hasVisibleViews(node *ast.Node) bool {\n    for _, id := range strings.Split(node.IALAttr('custom-av-visible-view-ids'), ',') {\n        if strings.TrimSpace(id) != '' {\n            return true\n        }\n    }\n    return false\n}","tryCatchPattern":"if _, err := validateTemplateAttributeViewNode(node, attrView); err != nil {\n    if strings.Contains(err.Error(), 'no available visible view') {\n        return fmt.Errorf('template node %s has empty visible-view list', node.ID)\n    }\n    return err\n}","preventionTips":["Never write empty or separator-only custom-av-visible-view-ids values","When clearing visible views programmatically, remove the attribute instead of emptying it","Validate templates after generating them with scripts or plugins"],"tags":["go","attribute-view","template","validation"],"backgroundTag":"empty-required-field","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"}