{"record":{"id":"6de217357d0608f4","repo":"siyuan-note/siyuan","slug":"clone-attribute-view-item-s-failed","errorCode":null,"errorMessage":"clone attribute view item [%s] failed","messagePattern":"clone attribute view item \\[(.+?)\\] failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_new_item.go","lineNumber":257,"sourceCode":"\tvar items []*itemDoc\n\tret := &CreateAttributeViewItemDocsResult{}\n\tfor _, itemID := range itemIDs {\n\t\tif \"\" == itemID || seen[itemID] {\n\t\t\tcontinue\n\t\t}\n\t\tseen[itemID] = true\n\t\tvalue := attrView.GetBlockValue(itemID)\n\t\tif nil == value || !value.IsDetached || nil == value.Block {\n\t\t\tret.SkippedItemIDs = append(ret.SkippedItemIDs, itemID)\n\t\t\tcontinue\n\t\t}\n\t\tpreview, resolveErr := resolveAttributeViewItemDocument(blockID, value.Block.Content, itemTemplate, createdAt)\n\t\tif nil != resolveErr {\n\t\t\treturn nil, resolveErr\n\t\t}\n\t\toriginal := value.Clone()\n\t\tif nil == original {\n\t\t\treturn nil, fmt.Errorf(\"clone attribute view item [%s] failed\", itemID)\n\t\t}\n\t\titems = append(items, &itemDoc{itemID: itemID, original: original, preview: preview})\n\t\tret.Warnings = append(ret.Warnings, preview.Warnings...)\n\t}\n\tif 0 == len(items) {\n\t\treturn ret, nil\n\t}\n\n\tcleanupCreatedDocs := func() error {\n\t\tvar cleanupErr error\n\t\tfor i := len(items) - 1; 0 <= i; i-- {\n\t\t\tif \"\" != items[i].docID {\n\t\t\t\tcleanupErr = errors.Join(cleanupErr, removeCreatedNewItemDoc(items[i].docID))\n\t\t\t}\n\t\t}\n\t\treturn cleanupErr\n\t}\n\tfor _, item := range items {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_new_item.go#L239-L275","documentation":"Inside CreateAttributeViewItemDocs, each detached item's av.Value is cloned before building the bound (attached) replacement value. av.Value.Clone() returning nil signals the clone failed or produced an unusable value; the function aborts that item with this wrapped error. It is a defensive check against an unexpected nil clone of an in-memory attribute-view row.","triggerScenarios":"CreateAttributeViewItemDocs is called with itemIDs whose row value passes the IsDetached/Block-non-nil filter, but value.Clone() unexpectedly returns nil (corrupt or malformed value data in the .av JSON, e.g. a Block value missing expected internals).","commonSituations":"Manually edited or partially synced attribute-view JSON files; items converted by an older version producing values the current Clone cannot represent; concurrent modification of the .av file while docs are being created.","solutions":["Reload the attribute view (close/reopen the database or restart the kernel) and retry CreateAttributeViewItemDocs; if it persists, inspect the item's row in the .av JSON for malformed block-value fields","Exclude the offending itemID from the itemIDs list and convert remaining items; re-create the problematic row manually","If caused by concurrent edits, retry after sync/idle so the .av file is stable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if v := attrView.GetBlockValue(itemID); v == nil || v.Block == nil {\n    return fmt.Errorf(\"item %s has unusable block value\", itemID)\n}","typeGuard":"func usableDetachedValue(v *av.Value) bool { return v != nil && v.IsDetached && v.Block != nil }","tryCatchPattern":"res, err := model.CreateAttributeViewItemDocs(avID, blockID, mode, itemIDs)\nif err != nil && strings.Contains(err.Error(), \"clone attribute view item\") {\n    // skip corrupt item and retry with remaining IDs\n}","preventionTips":["Do not hand-edit .av JSON files","Exclude items failing this check and retry the batch without them","Keep the kernel version uniform across synced devices"],"tags":["attribute-view","clone-failed","go-kernel"],"backgroundTag":"internal-invariant-violation","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}