siyuan-note/siyuan · error

attribute view [ ] view [ ] not found

Error message

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

What it means

validateTemplateAttributeViewNode checks that the view ID recorded in the attribute-view node's `custom-view-id` IAL actually exists in the parsed attribute view. When av.AttributeView.GetView(viewID) returns nil, this error names both the attribute view ID and the missing view ID, and template rendering stops. It guards against template blocks pointing at views that no longer exist.

Solutions

  1. Point the node's view attribute at an existing view ID in the target attribute view
  2. Remove the view attribute so the first available view is used instead
  3. Recreate the deleted view, or re-export the template so view IDs match the shipped database
  4. Open the database in the UI and confirm the view exists before inserting the template

Example fix

<!-- before -->
<div custom-av-view="20240101120000-deleted1" ...></div>
<!-- after -->
<div ...></div>  <!-- no custom-av-view: falls back to first view -->
Defensive patterns

Strategy: validation

Validate before calling

const av = await getAttrView(avID);
if (viewID && !av.views.some(v => v.id === viewID)) {
  // clear custom-av-view so the first view is used
  await setBlockAttrs(blockID, {"custom-av-view": ""});
}

Try / catch

try {
  await insertTemplate(path);
} catch (e) {
  if (String(e).includes("view [").includes("not found")) {
    await stripViewAttrAndRetry(blockID, path);
  }
}

Prevention

When it happens

Trigger: A template block references an attribute view via `custom-av-view` (av.NodeAttrView) whose ID is not among attrView.Views: the view was deleted, the template was copied without its source database, or IDs were regenerated. Raised while rendering templates containing attribute-view nodes in reference or copy mode.

Common situations: Deleting a view from a database that a template still targets, sharing templates as raw .sy text without the referenced database, or renaming/regenerating view IDs with external tooling.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/7f1def2ae2629400. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/template.go:579

func templateAttributeViewMode(node *ast.Node) (ret TemplateDatabaseMode, err error) {
	value := strings.TrimSpace(node.IALAttr(templateDatabaseModeAttr))
	if "" == value {
		return TemplateDatabaseModeCopy, nil
	}
	ret = TemplateDatabaseMode(value)
	if TemplateDatabaseModeCopy != ret && TemplateDatabaseModeReference != ret {
		return "", fmt.Errorf("unsupported template database mode [%s]", value)
	}
	return
}

func validateTemplateAttributeViewNode(node *ast.Node, attrView *av.AttributeView) (selectedView *av.View, err error) {
	viewID := strings.TrimSpace(node.IALAttr(av.NodeAttrView))
	if "" != viewID {
		selectedView = attrView.GetView(viewID)
		if nil == selectedView {
			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)

View on GitHub (pinned to 9f775e8a12)