siyuan-note/siyuan · error
clone attribute view
Error message
clone attribute view [%s] views failed
What it means
After cloning, copyTemplateAttributeView asserts the clone preserved the view list: len(source.Views) must equal len(target.Views). A mismatch means the clone dropped or duplicated views, so the copy would mis-map view IDs; this error aborts the template render. It is a defensive consistency check on the clone result.
Solutions
- Retry the template insert after closing other editors touching the same database
- Update SiYuan if a recent version changed attribute-view cloning; report the mismatch otherwise
- Recreate/re-export the source database to get consistent view data
- Check the source attribute view JSON for duplicated or malformed view entries
Defensive patterns
Strategy: retry
Validate before calling
const av = await getAttrView(avID);
if (new Set(av.views.map(v => v.id)).size !== av.views.length) {
console.warn("duplicate view IDs in source attribute view");
} Try / catch
try {
await insertTemplate(path);
} catch (e) {
if (String(e).includes("views failed")) {
await sleep(200); await insertTemplate(path); // retry after concurrent writers settle
}
} Prevention
- Avoid rendering templates while the same database is open for editing elsewhere
- Report persistent clone mismatches as av-package bugs with the database JSON
- Restore databases from history rather than patching cloned output
When it happens
Trigger: Copy-mode template rendering where av.AttributeView.Clone() returns a target whose Views slice length differs from the source — an internal inconsistency in the clone implementation or with concurrently mutated source data.
Common situations: Upstream av package changes that alter Clone semantics, race-y access to the source attribute view while it is being modified, or corrupted source data producing a partial clone.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- attribute view rich text style entity sentinel was not…
- attribute view [ ] template plan not found
- clone attribute view
- clone attribute view
- clone attribute view text value
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/f34d00fabc29065e.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/template.go:622
}
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)
}
if len(source.Views) != len(target.Views) {
return nil, fmt.Errorf("clone attribute view [%s] views failed", source.ID)
}
copiedViewIDs := map[string]string{}
for i, sourceView := range source.Views {
if nil == sourceView || nil == target.Views[i] {
return nil, fmt.Errorf("clone attribute view [%s] view failed", source.ID)
}
copiedViewIDs[sourceView.ID] = target.Views[i].ID
}
return &templateAttributeViewCopy{target: target, copiedViewIDs: copiedViewIDs}, nil
}
func prepareTemplateAttributeViews(tree *parse.Tree, preview bool) (plans map[*ast.Node]*templateAttributeViewPlan,
copies []*templateAttributeViewCopy, err error) {
plans = map[*ast.Node]*templateAttributeViewPlan{}
referenceSources := map[string]*av.AttributeView{}
copySources := map[string]*av.AttributeView{}
copyBySourceID := map[string]*templateAttributeViewCopy{}
boxID := templateAttributeViewBoxID(tree)View on GitHub (pinned to 9f775e8a12)