{"record":{"id":"90cdcd68dcca9671","repo":"siyuan-note/siyuan","slug":"bind-attribute-view-item-s-failed-w","errorCode":null,"errorMessage":"bind attribute view item [%s] failed: %w","messagePattern":"bind attribute view item \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_new_item.go","lineNumber":283,"sourceCode":"\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 {\n\t\titem.docID, item.tree, err = createAttributeViewItemDocument(item.preview, itemTemplate)\n\t\tif nil != err {\n\t\t\treturn nil, newItemCreationError(err, cleanupCreatedDocs())\n\t\t}\n\t\ticon, _ := getNodeAvBlockText(item.tree.Root, \"\")\n\t\titem.bound, err = newBoundAttributeViewItemValue(item.original, item.docID, icon)\n\t\tif nil != err {\n\t\t\treturn nil, newItemCreationError(fmt.Errorf(\"bind attribute view item [%s] failed: %w\", item.itemID, err), cleanupCreatedDocs())\n\t\t}\n\t\tret.ItemIDs = append(ret.ItemIDs, item.itemID)\n\t\tret.BlockIDs = append(ret.BlockIDs, item.docID)\n\t}\n\n\tvar doOperations, undoOperations []*Operation\n\tfor _, item := range items {\n\t\tdoOperations = append(doOperations,\n\t\t\t&Operation{Action: \"restoreCreatedDoc\", ID: item.docID, Tree: item.tree},\n\t\t\t&Operation{\n\t\t\t\tAction: \"replaceAttrViewBlock\", AvID: avID, BlockID: blockID, PreviousID: item.itemID, NextID: item.docID,\n\t\t\t\tIsDetached: false,\n\t\t\t},\n\t\t\t&Operation{\n\t\t\t\tAction: \"updateAttrViewCell\", ID: item.bound.ID, AvID: avID, KeyID: item.bound.KeyID,\n\t\t\t\tRowID: item.itemID, Data: item.bound,\n\t\t\t},\n\t\t)","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_new_item.go#L265-L301","documentation":"After a document is created for a detached item, CreateAttributeViewItemDocs builds the bound value via newBoundAttributeViewItemValue. Any error from that step is wrapped as \"bind attribute view item [%s] failed: %w\" and, because docs were already created, the returned newItemCreationError also carries cleanup results (created docs are removed). It means the item row could not be converted into a block-bound value for the newly created document.","triggerScenarios":"CreateAttributeViewItemDocs on an item whose cloned value loses its Block field during Clone (newBoundAttributeViewItemValue returns \"clone attribute view item failed\"), which is then wrapped with the item ID by this error.","commonSituations":"Same malformed/corrupt .av row data as the clone failure; race where the row is edited between reading and binding; batch conversion interrupted by sync rewriting the attribute view mid-run.","solutions":["Read the wrapped %w cause: it is almost always \"clone attribute view item failed\"; fix the underlying malformed value (recreate the row) and retry","Check the appended cleanup error to see whether leftover created documents need manual deletion in the doc tree","Retry the batch after sync settles, excluding the item that failed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func bindable(v *av.Value) bool { return v != nil && v.Clone() != nil && v.Clone().Block != nil }","tryCatchPattern":"res, err := model.CreateAttributeViewItemDocs(avID, blockID, mode, itemIDs)\nif err != nil {\n    var ce error\n    if errors.As(err, &ce) { /* inspect wrapped clone error and cleanup error */ }\n}","preventionTips":["Avoid concurrent edits/sync while batch-converting items to documents","Check the cleanup error portion for leftover documents","Recreate rows whose values fail to clone"],"tags":["attribute-view","bind-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"}