siyuan-note/siyuan · error

attribute view group not found

Error message

attribute view group not found

What it means

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.

Solutions

  1. Refetch the attribute view and rebuild change.RowOrder.Groups from the current view.Groups, then retry the drag
  2. Discard the stale drag state on the client and restart the drag-and-drop interaction
  3. If constructing RowOrder programmatically, iterate view.Groups and add every group ID (even unchanged ones) to the map

Example fix

// before
rowOrder.Groups["old-group-id"] = ids
// after
for _, group := range view.Groups {
    if _, ok := rowOrder.Groups[group.ID]; !ok {
        rowOrder.Groups[group.ID] = currentOrderFor(group)
    }
}
Defensive patterns

Strategy: retry

Validate before calling

// caller-side, before submitting
missing := view.Groups.filter(g => !(g.id in rowOrder.groups))
if (missing.length > 0) throw new StaleDragError(missing)

Try / catch

try {
  await api.sortAttributeViewRow(change);
} catch (e) {
  if (String(e.msg).includes("attribute view group not found") ||
      String(e.msg).includes("groups changed")) {
    change = rebuildRowOrder(await api.getAttributeView(avID)); // refresh & retry
    await api.sortAttributeViewRow(change);
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/f340660fc17c51ee. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/attribute_view_row_sort.go:243

func applyAttributeViewRowOrder(attrView *av.AttributeView, view *av.View, data any) error {
	encoded, err := gulu.JSON.MarshalJSON(data)
	if nil != err {
		return err
	}
	var change attributeViewRowOrderChange
	if err = gulu.JSON.UnmarshalJSON(encoded, &change); nil != err {
		return err
	}
	if nil == change.RowOrder || nil == change.Expected ||
		!reflect.DeepEqual(getAttributeViewRowOrder(view), change.Expected) {
		return errors.New("attribute view order changed; retry the drag")
	}
	if len(change.RowOrder.Groups) != len(view.Groups) {
		return errors.New("attribute view groups changed; retry the drag")
	}
	for _, group := range view.Groups {
		if _, ok := change.RowOrder.Groups[group.ID]; !ok {
			return errors.New("attribute view group not found")
		}
	}
	if nil != change.ValidateGroup && len(change.RowOrder.Sorts) > 0 {
		// 预览之后字段值可能变化,提交时再次校验,不能悄悄接受冲突的落点。
		copyView, copyErr := cloneAttributeViewRowSort(attrView)
		if nil != copyErr {
			return copyErr
		}
		candidate := copyView.GetView(view.ID)
		setAttributeViewRowOrder(candidate, change.RowOrder)
		collections, renderErr := renderAttributeViewRowSortCollections(copyView, candidate, false)
		if nil != renderErr {
			return renderErr
		}
		collection := collections[*change.ValidateGroup]
		if nil == collection {
			return av.ErrViewNotFound
		}

View on GitHub (pinned to 9f775e8a12)