siyuan-note/siyuan · error

parse attribute view

Error message

parse attribute view [%s] in box [%s] failed: %w

What it means

In reference mode, prepareTemplateAttributeViews parses the source attribute view from the template's box via av.ParseAttributeViewInBox. If that parse returns an error (unreadable or malformed database data for that box), the walk stops and the underlying error is wrapped with the attribute view ID and box ID. This distinguishes a parse failure from the separate 'not found in box' case that follows.

Solutions

  1. Check and repair the referenced attribute view by opening it in the UI; restore storage/av data from sync history or backup if it fails
  2. Move the template back into the box containing the referenced database, or change the block to copy mode
  3. Validate the attribute view JSON for syntax/schema damage before reloading
  4. Recreate the referenced database and update the template's attribute-view ID

Example fix

<!-- before: reference mode with missing/corrupt source -->
<div custom-av-mode="reference" data-type="NodeAttributeView" data-av-id="20240101120000-abc"></div>
<!-- after: copy mode falls back to embedded data -->
<div custom-av-mode="copy" data-type="NodeAttributeView" data-av-id="20240101120000-abc"></div>
Defensive patterns

Strategy: try-catch

Validate before calling

try {
  const av = await getAttrViewByID(avID);
  if (!av) throw new Error(`attribute view ${avID} not readable in box`);
} catch (e) { /* repair or switch to copy mode before rendering */ }

Try / catch

try {
  await insertTemplate(path);
} catch (e) {
  if (String(e).includes("parse attribute view")) {
    await restoreAttrViewFromHistory(avID); // or rewrite block to custom-av-mode=copy
  }
}

Prevention

When it happens

Trigger: Rendering a template whose database block uses `custom-av-mode="reference"` while ParseAttributeViewInBox(attributeViewID, boxID) fails — the storage/av JSON for that ID in the box is malformed, unreadable, or fails parsing/validation inside the av package. In encrypted boxes the parse is scoped to the box ID; a wrong or inaccessible box triggers the same wrap.

Common situations: Databases corrupted by interrupted sync or disk issues, templates moved between boxes so the referenced database is absent in the current box's encrypted storage, or manual edits to storage/av/*.json breaking the schema.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/template.go:656

	copySources := map[string]*av.AttributeView{}
	copyBySourceID := map[string]*templateAttributeViewCopy{}
	boxID := templateAttributeViewBoxID(tree)
	ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
		if !entering || ast.NodeAttributeView != n.Type {
			return ast.WalkContinue
		}

		mode, modeErr := templateAttributeViewMode(n)
		if nil != modeErr {
			err = modeErr
			return ast.WalkStop
		}
		if TemplateDatabaseModeReference == mode {
			source := referenceSources[n.AttributeViewID]
			if nil == source {
				source, modeErr = av.ParseAttributeViewInBox(n.AttributeViewID, boxID)
				if nil != modeErr {
					err = fmt.Errorf("parse attribute view [%s] in box [%s] failed: %w", n.AttributeViewID, boxID, modeErr)
					return ast.WalkStop
				}
				if nil == source || source.ID != n.AttributeViewID {
					err = fmt.Errorf("attribute view [%s] not found in box [%s]", n.AttributeViewID, boxID)
					return ast.WalkStop
				}
				referenceSources[n.AttributeViewID] = source
			}
			selectedView, validateErr := validateTemplateAttributeViewNode(n, source)
			if nil != validateErr {
				err = validateErr
				return ast.WalkStop
			}
			plans[n] = &templateAttributeViewPlan{
				mode: mode, source: source, target: source, selectedView: selectedView,
			}
			return ast.WalkContinue
		}

View on GitHub (pinned to 9f775e8a12)