siyuan-note/siyuan · error

attribute view [%s] visible view [%s] not found

Error message

attribute view [%s] visible view [%s] not found

What it means

If the template node sets the visible-view-ids IAL (av.NodeAttrVisibleViewIDs), each listed view ID must exist in the attribute view. This error reports the first visible-view ID that no longer resolves — typically a view deleted after the template captured its visible-view list.

Source

Thrown at kernel/model/template.go:513

			return nil, fmt.Errorf("attribute view [%s] view [%s] not found", attrView.ID, viewID)
		}
	} else if selectedView, err = attrView.GetFirstView(); nil != err {
		return nil, fmt.Errorf("attribute view [%s] has no available view: %w", attrView.ID, err)
	}

	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
}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Re-save the template from a document whose database still has all listed visible views
  2. Edit the template custom-av-visible-view-ids attribute to list only existing view IDs
  3. Remove the custom-av-visible-view-ids attribute so default view behavior applies

Example fix

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

Strategy: validation

Validate before calling

for _, id := range strings.Split(node.IALAttr('custom-av-visible-view-ids'), ',') {
    if id = strings.TrimSpace(id); id != '' && attrView.GetView(id) == nil {
        // prune the stale ID before validation
    }
}

Type guard

func allVisibleViewsExist(attrView *av.AttributeView, ids string) bool {
    for _, id := range strings.Split(ids, ',') {
        if id = strings.TrimSpace(id); id != '' && attrView.GetView(id) == nil {
            return false
        }
    }
    return true
}

Try / catch

if _, err := validateTemplateAttributeViewNode(node, attrView); err != nil {
    if strings.Contains(err.Error(), 'visible view') {
        return fmt.Errorf('template references deleted view: %w', err)
    }
    return err
}

Prevention

When it happens

Trigger: Instantiating a template whose database block lists visible view IDs, one of which was deleted or renamed in the source attribute view.

Common situations: Templates exported before views were deleted, hand-edited visible-view-ID lists, or databases merged or modified after the template was saved.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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