{"record":{"id":"b6b3d4bdeb9774ad","repo":"siyuan-note/siyuan","slug":"attribute-view-rows-changed-retry-the-drag","errorCode":null,"errorMessage":"attribute view rows changed; retry the drag","messagePattern":"attribute view rows changed; retry the drag","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/attribute_view_row_sort.go","lineNumber":187,"sourceCode":"\nfunc moveAttributeViewSortedRows(ordered, selected []string, previousID, nextID string) ([]string, error) {\n\tselectedIDs := map[string]bool{}\n\tfor _, id := range selected {\n\t\tselectedIDs[id] = true\n\t}\n\tif 0 == len(selectedIDs) {\n\t\treturn nil, errors.New(\"no attribute view rows selected\")\n\t}\n\tvar moved, remaining []string\n\tfor _, id := range ordered {\n\t\tif selectedIDs[id] {\n\t\t\tmoved = append(moved, id)\n\t\t} else {\n\t\t\tremaining = append(remaining, id)\n\t\t}\n\t}\n\tif len(moved) != len(selectedIDs) {\n\t\treturn nil, errors.New(\"attribute view rows changed; retry the drag\")\n\t}\n\tif selectedIDs[nextID] || (\"\" == nextID && selectedIDs[previousID]) {\n\t\treturn slices.Clone(ordered), nil\n\t}\n\tindex := 0\n\tif \"\" != nextID {\n\t\tindex = slices.Index(remaining, nextID)\n\t} else if \"\" != previousID {\n\t\tindex = slices.Index(remaining, previousID)\n\t\tif index >= 0 {\n\t\t\tindex++\n\t\t}\n\t}\n\tif index < 0 {\n\t\treturn nil, errors.New(\"attribute view drop target changed; retry the drag\")\n\t}\n\tret := append([]string{}, remaining[:index]...)\n\tret = append(ret, moved...)","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_row_sort.go#L169-L205","documentation":"During a row-drag move, moveAttributeViewSortedRows partitions the current ordered row list into moved (selected) and remaining rows. If the number of moved rows found in the ordered list differs from the number of selected IDs, some selected rows no longer exist in the current order — the view changed underneath the drag. The kernel rejects the stale operation and tells the client to retry the drag.","triggerScenarios":"Dragging rows where one or more selected row IDs are absent from the current ordered view: rows deleted by another client/session between preview and drop, rows filtered out by changed filter/sort conditions, or a stale preview computed against an older snapshot.","commonSituations":"Two browser windows open on the same database, one deleting rows while the other drags; a filter change mid-drag; a plugin mutating the attribute view while the user drags; replaying an old drag payload after sync updated the view.","solutions":["Re-fetch the current view state and have the user repeat the drag.","Verify no concurrent editor deleted the selected rows between preview and drop.","Refresh filters/sorts so the selected rows are present in the rendered view, then retry.","Make the client discard the stale RowOrder payload and recompute it from the fresh view."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await commitRowDrag(payload);\n} catch (e) {\n  if (String(e.msg).includes(\"rows changed; retry\")) {\n    const fresh = await fetchAttributeView(avID);\n    rebuildDragPayload(fresh); // then let the user retry\n  }\n}","preventionTips":["Close or sync other editor windows before long drags on shared databases","Commit drags promptly; do not hold a preview open across other edits"],"tags":["go","attribute-view","concurrency","optimistic-concurrency"],"backgroundTag":"invalid-state-transition","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"}