{"record":{"id":"35240382b3663575","repo":"siyuan-note/siyuan","slug":"attribute-view-groups-changed-retry-the-drag","errorCode":null,"errorMessage":"attribute view groups changed; retry the drag","messagePattern":"attribute view groups changed; retry the drag","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/attribute_view_row_sort.go","lineNumber":239,"sourceCode":"\t}\n\treturn ret\n}\n\nfunc applyAttributeViewRowOrder(attrView *av.AttributeView, view *av.View, data any) error {\n\tencoded, err := gulu.JSON.MarshalJSON(data)\n\tif nil != err {\n\t\treturn err\n\t}\n\tvar change attributeViewRowOrderChange\n\tif err = gulu.JSON.UnmarshalJSON(encoded, &change); nil != err {\n\t\treturn err\n\t}\n\tif nil == change.RowOrder || nil == change.Expected ||\n\t\t!reflect.DeepEqual(getAttributeViewRowOrder(view), change.Expected) {\n\t\treturn errors.New(\"attribute view order changed; retry the drag\")\n\t}\n\tif len(change.RowOrder.Groups) != len(view.Groups) {\n\t\treturn errors.New(\"attribute view groups changed; retry the drag\")\n\t}\n\tfor _, group := range view.Groups {\n\t\tif _, ok := change.RowOrder.Groups[group.ID]; !ok {\n\t\t\treturn errors.New(\"attribute view group not found\")\n\t\t}\n\t}\n\tif nil != change.ValidateGroup && len(change.RowOrder.Sorts) > 0 {\n\t\t// 预览之后字段值可能变化，提交时再次校验，不能悄悄接受冲突的落点。\n\t\tcopyView, copyErr := cloneAttributeViewRowSort(attrView)\n\t\tif nil != copyErr {\n\t\t\treturn copyErr\n\t\t}\n\t\tcandidate := copyView.GetView(view.ID)\n\t\tsetAttributeViewRowOrder(candidate, change.RowOrder)\n\t\tcollections, renderErr := renderAttributeViewRowSortCollections(copyView, candidate, false)\n\t\tif nil != renderErr {\n\t\t\treturn renderErr\n\t\t}","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_row_sort.go#L221-L257","documentation":"applyAttributeViewRowOrder also validates group structure: the submitted RowOrder.Groups map must cover exactly the same number of groups as the view currently has. If the counts differ (groups added, removed, or regrouped since the preview), the order payload is stale or structurally wrong, so the commit fails with this error and the client must retry the drag against the fresh view.","triggerScenarios":"Committing a drag on a grouped attribute view after a cell value changed such that a row regrouped (group count changed), after another session added/removed a group, or when the client built RowOrder.Groups against an older grouping.","commonSituations":"Group-by views where editing a grouping field during/after the drag moves the row between groups; collaborative sessions where one user changes the group-by configuration while another drags; stale previews held open across a sync that regrouped rows.","solutions":["Re-render the attribute view, rebuild the RowOrder payload for the current groups, and redo the drag.","Check whether the group-by field value changed during the drag and account for the new grouping before committing.","Avoid holding a preview open while group-affecting edits are possible; commit promptly or refresh first.","If a plugin constructs RowOrder, generate its Groups map from the live view.Groups rather than a cached copy."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (Object.keys(payload.rowOrder?.groups ?? {}).length !== currentView.groups.length) {\n  // stale group structure: re-render and rebuild the payload before committing\n}","typeGuard":null,"tryCatchPattern":"try {\n  await applyAttributeViewRowOrder(payload);\n} catch (e) {\n  if (String(e.msg).includes(\"groups changed; retry\")) {\n    const fresh = await fetchAttributeView(avID);\n    payload.rowOrder.groups = buildGroupsMap(fresh);\n    // retry the reorder on the fresh grouping\n  }\n}","preventionTips":["Avoid editing group-by field values while a drag preview is open on a grouped view","Rebuild the RowOrder.Groups map from the live view.Groups whenever the grouping changes"],"tags":["go","attribute-view","groups","stale-state"],"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"}