{"record":{"id":"e25ebfb38cbbbd63","repo":"siyuan-note/siyuan","slug":"clone-attribute-view-value-s-failed","errorCode":null,"errorMessage":"clone attribute view value [%s] failed","messagePattern":"clone attribute view value \\[(.+?)\\] failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_binding.go","lineNumber":35,"sourceCode":"\t\treturn nil\n\t}\n\tvalues := map[string]*av.Value{}\n\tfor _, cell := range cells {\n\t\tif cell == nil {\n\t\t\treturn av.ErrKeyNotFound\n\t\t}\n\t\tif cell.KeyID != key.ID {\n\t\t\tcontinue\n\t\t}\n\t\tvalue := values[cell.RowID]\n\t\tif value == nil {\n\t\t\toriginal := attrView.GetBlockValue(cell.RowID)\n\t\t\tif original == nil {\n\t\t\t\treturn av.ErrItemNotFound\n\t\t\t}\n\t\t\tvalue = original.Clone()\n\t\t\tif value == nil {\n\t\t\t\treturn fmt.Errorf(\"clone attribute view value [%s] failed\", original.ID)\n\t\t\t}\n\t\t\tvalues[cell.RowID] = value\n\t\t}\n\t\tdata, err := gulu.JSON.MarshalJSON(cell.Data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err = gulu.JSON.UnmarshalJSON(data, value); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !value.IsDetached {\n\t\t\tif value.Block == nil {\n\t\t\t\treturn ErrBlockNotFound\n\t\t\t}\n\t\t\t_, tree, loadErr := getNodeByBlockID(tx, value.Block.ID)\n\t\t\tif loadErr != nil {\n\t\t\t\treturn loadErr\n\t\t\t}","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_binding.go#L17-L53","documentation":"This error is returned when cloning an existing attribute view (database) row value fails during batch cell updates. Before applying new cell data, the transaction reads the current row value for the row ID and calls Value.Clone(); if the clone returns nil the transaction aborts, because continuing would mutate shared state and corrupt the database value cache.","triggerScenarios":"Calling UpdateAttrViewCells or BatchUpdateAttributeViewCells (kernel API updateAttrViewCell / batchUpdateAttrViewCell) where preflightAttributeViewCellBindings finds a row value via GetBlockValue(cell.RowID) whose Clone() yields nil — typically a zero-value or partially initialized av.Value whose underlying Block/map state cannot be safely deep-copied.","commonSituations":"Historic or index-degraded database rows whose value structs lack the expected sub-objects; concurrent transactions mutated the attribute view between read and clone; programmatic callers passing stale or fabricated row IDs built outside the normal binding flow.","solutions":["Refresh/reindex the affected notebook (rebuild database index) so GetBlockValue returns fully populated values","Verify each cell.RowID in the request corresponds to a real, currently bound row in the attribute view before calling the API","Update SiYuan to a version with a fixed av.Value.Clone implementation if you can reproduce with a valid row","Re-create the affected database row (detach and re-bind the block) to replace the corrupt value record"],"exampleFix":"// before\ncells := [{rowID: 'stale-or-fake-id', ...}]\napi.batchUpdateAttrViewCell(cells)\n// after\nconst row = av.rows.find(r => r.id === cell.rowID)\nif (!row) throw new Error('row not bound')\napi.batchUpdateAttrViewCell(cells)","handlingStrategy":"validation","validationCode":"const original = av.blockValues && av.blockValues[cell.rowID];\nif (!original || !original.id) throw new Error('row ' + cell.rowID + ' has no bindable value');","typeGuard":"function isBindableRow(v) {\n  return !!v && typeof v.id === 'string' && v.id !== '' && !!v.block;\n}","tryCatchPattern":null,"preventionTips":["Only send row IDs obtained from the attribute view API, never fabricated ones","Keep database indexes healthy; rebuild index after sync conflicts or crashes","Avoid concurrent writes to the same database from multiple windows or scripts","Test batch cell updates against copied documents first"],"tags":["database","attribute-view","clone-failed","internal-state"],"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"}