siyuan-note/siyuan · error

no attribute view rows selected

Error message

no attribute view rows selected

What it means

moveAttributeViewSortedRows computes a new row order for a drag-and-drop move in an attribute view. It requires a non-empty set of selected row IDs; if the selected list is empty (after deduplication), there is nothing to move, so it returns this error instead of producing a meaningless no-op order.

Solutions

  1. Ensure the drag payload includes at least one selected row ID before invoking the move.
  2. Check the frontend/plugin code that collects selected row IDs for a filtering bug.
  3. If rows may have been deleted concurrently, re-query the view and rebuild the selection, then retry.
  4. Guard the call: if selected.length === 0, skip the API call and show the user a no-op.

Example fix

// before
sortAttributeViewRow(avID, viewID, [])
// after
if (selectedRowIds.length > 0) { sortAttributeViewRow(avID, viewID, selectedRowIds); }
Defensive patterns

Strategy: validation

Validate before calling

if (!Array.isArray(selected) || selected.filter(id => id && id.trim()).length === 0) {
  return; // nothing to move, skip the API call
}

Type guard

function hasSelectedRows(sel) {
  return Array.isArray(sel) && sel.some(id => typeof id === "string" && id.length > 0);
}

Prevention

When it happens

Trigger: Calling the row-move path (via prepareAttributeViewRowSort / sortAttributeViewRow API) with selected as an empty array or a list of empty/whitespace IDs that deduplicate to nothing.

Common situations: A frontend bug dropping the selection before submitting the drag; a plugin calling the sort API programmatically without passing row IDs; a race where rows were deleted between preview and commit so the selection resolved to empty.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/attribute_view_row_sort.go:176

	}
	return ret, nil
}

func attributeViewRowSortIDs(items []av.Item) []string {
	ret := make([]string, 0, len(items))
	for _, item := range items {
		ret = append(ret, item.GetID())
	}
	return ret
}

func moveAttributeViewSortedRows(ordered, selected []string, previousID, nextID string) ([]string, error) {
	selectedIDs := map[string]bool{}
	for _, id := range selected {
		selectedIDs[id] = true
	}
	if 0 == len(selectedIDs) {
		return nil, errors.New("no attribute view rows selected")
	}
	var moved, remaining []string
	for _, id := range ordered {
		if selectedIDs[id] {
			moved = append(moved, id)
		} else {
			remaining = append(remaining, id)
		}
	}
	if len(moved) != len(selectedIDs) {
		return nil, errors.New("attribute view rows changed; retry the drag")
	}
	if selectedIDs[nextID] || ("" == nextID && selectedIDs[previousID]) {
		return slices.Clone(ordered), nil
	}
	index := 0
	if "" != nextID {
		index = slices.Index(remaining, nextID)

View on GitHub (pinned to 9f775e8a12)