{"record":{"id":"f340660fc17c51ee","repo":"siyuan-note/siyuan","slug":"attribute-view-group-not-found","errorCode":null,"errorMessage":"attribute view group not found","messagePattern":"attribute view group not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_row_sort.go","lineNumber":243,"sourceCode":"func 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}\n\t\tcollection := collections[*change.ValidateGroup]\n\t\tif nil == collection {\n\t\t\treturn av.ErrViewNotFound\n\t\t}","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_row_sort.go#L225-L261","documentation":"In applyAttributeViewRowOrder, SiYuan validates that a submitted drag-and-drop row order still matches the attribute view's current group set. If a group in the view has no entry in change.RowOrder.Groups, the submitted order is stale or incomplete and the mutation is rejected with this error. This guards against persisting a row order computed against an older snapshot of the view.","triggerScenarios":"Calling sortAttributeViewRow with an AttributeViewRowSortChange whose RowOrder.Groups map lacks an entry for one of the view's current group IDs — typically when the row order was captured before a group was added to the view, or the caller built the Groups map manually and omitted a group.","commonSituations":"A drag operation computed client-side, then a group/filter change altered the view before the order was submitted; a stale preview from before a grouping change (the code explicitly returns 'attribute view groups changed; retry the drag' first for count mismatches, and this error for ID-level mismatches); a programmatic caller constructing RowOrder by hand from an outdated view snapshot.","solutions":["Refetch the attribute view and rebuild change.RowOrder.Groups from the current view.Groups, then retry the drag","Discard the stale drag state on the client and restart the drag-and-drop interaction","If constructing RowOrder programmatically, iterate view.Groups and add every group ID (even unchanged ones) to the map"],"exampleFix":"// before\nrowOrder.Groups[\"old-group-id\"] = ids\n// after\nfor _, group := range view.Groups {\n    if _, ok := rowOrder.Groups[group.ID]; !ok {\n        rowOrder.Groups[group.ID] = currentOrderFor(group)\n    }\n}","handlingStrategy":"retry","validationCode":"// caller-side, before submitting\nmissing := view.Groups.filter(g => !(g.id in rowOrder.groups))\nif (missing.length > 0) throw new StaleDragError(missing)","typeGuard":null,"tryCatchPattern":"try {\n  await api.sortAttributeViewRow(change);\n} catch (e) {\n  if (String(e.msg).includes(\"attribute view group not found\") ||\n      String(e.msg).includes(\"groups changed\")) {\n    change = rebuildRowOrder(await api.getAttributeView(avID)); // refresh & retry\n    await api.sortAttributeViewRow(change);\n  }\n}","preventionTips":["Always rebuild RowOrder.Groups from the freshly fetched view.Groups immediately before submitting","Recompute drag state after any grouping/filter change instead of reusing cached previews","Never construct the Groups map by hand from stale data"],"tags":["attribute-view","stale-data","drag-and-drop","retry"],"backgroundTag":"stale-data-conflict","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"}