siyuan-note/siyuan · error

attribute view sort values changed; retry the drag

Error message

attribute view sort values changed; retry the drag

What it means

applyAttributeViewRowOrder revalidates the submitted row sort at commit time: it clones the view, applies av.Sort on the cloned collection, and compares item order before/after. If sorting by current field values would reorder items relative to the order captured when the drag preview was made, the values have changed in the meantime and the mutation is rejected with this error instead of silently persisting a conflicting drop position.

Solutions

  1. Retry the drag: recompute the preview and resubmit sortAttributeViewRow against the refreshed view
  2. If values changed intentionally, let the active sort reapply (or clear the view sort) before performing the drag
  3. Avoid holding drag state across long delays; commit promptly after the user drops

Example fix

// before
applyRowOrder(change) // stale preview, values changed
// after
err := sortAttributeViewRow(change) // returns "...retry the drag"
if err != nil {
    change = recomputePreview(attrView, dragInfo) // refresh then retry
    err = sortAttributeViewRow(change)
}
Defensive patterns

Strategy: retry

Validate before calling

// preview, then submit quickly; on server this is validated via clone+av.Sort
const preview = await api.getAttributeViewPreview(avID);

Try / catch

try {
  await api.sortAttributeViewRow(change);
} catch (e) {
  if (String(e.msg).includes("sort values changed")) {
    const fresh = await api.getAttributeView(avID);
    await api.sortAttributeViewRow(recomputeRowOrder(fresh, change.Sorts));
  }
}

Prevention

When it happens

Trigger: Calling sortAttributeViewRow with change.ValidateGroup set and RowOrder.Sorts non-empty, where the rows' sort-field values changed between preview and submission so that applying the sort produces a different item sequence than the submitted RowOrder.

Common situations: A user or a sync/automation edited a cell in a sort-relevant column while a drag was in progress; collaborative or background updates landed between the preview computation and the commit; a long-delayed drag submission against an active sort.

Related errors


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

Appendix: source

Thrown at kernel/model/attribute_view_row_sort.go:265

		// 预览之后字段值可能变化,提交时再次校验,不能悄悄接受冲突的落点。
		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
		}
		ordered := attributeViewRowSortIDs(collection.GetItems())
		av.Sort(collection.(av.Viewable), copyView)
		if !slices.Equal(ordered, attributeViewRowSortIDs(collection.GetItems())) {
			return errors.New("attribute view sort values changed; retry the drag")
		}
	}
	setAttributeViewRowOrder(view, change.RowOrder)
	return nil
}

func isAttributeViewRowOrderOperation(data any) bool {
	switch value := data.(type) {
	case *attributeViewRowOrderChange:
		return nil != value
	case map[string]any:
		_, ok := value["rowOrder"]
		return ok
	}
	return false
}

func setAttributeViewRowOrder(view *av.View, order *attributeViewRowOrder) {

View on GitHub (pinned to 9f775e8a12)