siyuan-note/siyuan · error

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

Error message

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

What it means

When a template embeds a database in reference mode, the kernel must load the referenced attribute view from the notebook (box) via av.ParseAttributeViewInBox. This error wraps the underlying parse failure (I/O, JSON decode, lock error) with the attribute view ID and box ID for diagnosis.

Source

Thrown at kernel/model/template.go:572

	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 8641553a1f)

Solutions

  1. Check that the referenced attribute view still exists under the box's storage (data/storage/av/<id>.av) and is valid JSON
  2. Remove the stale database node from the template or update its AttributeViewID to an existing database
  3. Check kernel logs (the wrapped %w cause) for the underlying I/O or lock error and fix that first (permissions, disk space, sync conflicts)

Example fix

// before: template references a deleted database id
{{database id="20240101120000-abcdefg"}}
// after: point the node at an existing attribute view
{{database id="20240101120000-existing"}}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the referenced database file exists before rendering
if _, statErr := os.Stat(filepath.Join(boxStorageDir, "av", avID+".av")); statErr != nil {
    return fmt.Errorf("referenced attribute view %s missing", avID)
}

Try / catch

if _, err := av.ParseAttributeViewInBox(avID, boxID); err != nil {
    logging.LogErrorf("cannot resolve referenced av %s in box %s: %v", avID, boxID, err)
    // fall back to copy mode or skip the node
}

Prevention

When it happens

Trigger: Rendering a template whose database node references attribute view ID X in box B, and ParseAttributeViewInBox fails (missing/unreadable .av file, JSON corruption, file lock timeout).

Common situations: Template referencing a database that was deleted or whose storage file was removed by an incomplete sync; encrypted-box key issues preventing read; disk permission problems.

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@8641553a1f (2026-09-11). Data as JSON: /api/errors/a6c5e2eb88283f3c. Report an issue: GitHub.