siyuan-note/siyuan · error

attribute view [%s] has no available visible view

Error message

attribute view [%s] has no available visible view

What it means

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.

Source

Thrown at kernel/model/template.go:517

	}

	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 {
		return nil, fmt.Errorf("attribute view [%s] has no available visible view", attrView.ID)
	}
	return
}

func resolveCopyTemplateAttributeView(node *ast.Node, attrView *av.AttributeView) *av.View {
	if viewID := strings.TrimSpace(node.IALAttr(av.NodeAttrView)); "" != viewID {
		if view := attrView.GetView(viewID); nil != view {
			return view
		}
	}
	view, _ := attrView.GetFirstView()
	return view
}

func copyTemplateAttributeView(source *av.AttributeView) (ret *templateAttributeViewCopy, err error) {
	target := source.Clone()
	if nil == target {
		return nil, fmt.Errorf("clone attribute view [%s] failed", source.ID)

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Set custom-av-visible-view-ids to at least one valid existing view ID
  2. Remove the attribute entirely so the default (first view) applies
  3. Re-save the template through the SiYuan UI to regenerate a correct attribute value

Example fix

// before (database block IAL in template)
{: custom-av-visible-view-ids=',,'}
// after
{: custom-av-visible-view-ids='20240101120000-abc'}
Defensive patterns

Strategy: validation

Validate before calling

ids := node.IALAttr('custom-av-visible-view-ids')
hasAny := false
for _, id := range strings.Split(ids, ',') {
    if strings.TrimSpace(id) != '' {
        hasAny = true
        break
    }
}
if ids != '' && !hasAny {
    node.RemoveIALAttr('custom-av-visible-view-ids') // fall back to defaults
}

Type guard

func hasVisibleViews(node *ast.Node) bool {
    for _, id := range strings.Split(node.IALAttr('custom-av-visible-view-ids'), ',') {
        if strings.TrimSpace(id) != '' {
            return true
        }
    }
    return false
}

Try / catch

if _, err := validateTemplateAttributeViewNode(node, attrView); err != nil {
    if strings.Contains(err.Error(), 'no available visible view') {
        return fmt.Errorf('template node %s has empty visible-view list', node.ID)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: A plugin or script wiping the attribute value, manual editing leaving only separators, or sync conflicts producing an emptied attribute.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/7c2577ea70fd8e26. Report an issue: GitHub.