{"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":601,"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":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template.go#L583-L619","documentation":"After iterating the node's `custom-visible-view-ids` list, validateTemplateAttributeViewNode requires at least one non-empty, resolvable visible view. If the attribute is present but contains only blanks (e.g. empty strings after trimming between commas), zero visibleViewCount triggers this error. It prevents rendering a database block with no selectable visible view.","triggerScenarios":"A template attribute-view node has `custom-visible-view-ids` set but its comma-split entries are all empty (attribute like `\",,\"` or whitespace-only), so the loop counts zero valid IDs. Raised during template render.","commonSituations":"Clearing the attribute's value without removing the key, programmatic IAL edits that leave the attribute blank, or templates generated by tooling that writes empty lists.","solutions":["Remove the custom-visible-view-ids attribute entirely when all views should be available","Populate it with at least one existing view ID","Fix tooling that writes empty visible-view lists into template IAL"],"exampleFix":"<!-- before -->\n<div custom-visible-view-ids=\", ,\" ...></div>\n<!-- after -->\n<div ...></div>","handlingStrategy":"validation","validationCode":"const v = attrs[\"custom-visible-view-ids\"];\nif (v !== undefined && !String(v).split(\",\").some(s => s.trim())) {\n  await setBlockAttrs(blockID, {\"custom-visible-view-ids\": \"\"}); // or remove key\n}","typeGuard":null,"tryCatchPattern":"try {\n  await insertTemplate(path);\n} catch (e) {\n  if (String(e).includes(\"has no available visible view\")) {\n    await removeAttrAndRetry(blockID, \"custom-visible-view-ids\");\n  }\n}","preventionTips":["Remove the attribute key instead of blanking its value when clearing a list","Sanitize IAL writes from scripts so empty lists become absent attributes","Audit generated templates for empty comma-only attribute values"],"tags":["attribute-view","template","empty"],"backgroundTag":"empty-required-field","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"}