{"record":{"id":"d5e379d7bcf27b29","repo":"siyuan-note/siyuan","slug":"no-attribute-view-rows-selected","errorCode":null,"errorMessage":"no attribute view rows selected","messagePattern":"no attribute view rows selected","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_row_sort.go","lineNumber":176,"sourceCode":"\t}\n\treturn ret, nil\n}\n\nfunc attributeViewRowSortIDs(items []av.Item) []string {\n\tret := make([]string, 0, len(items))\n\tfor _, item := range items {\n\t\tret = append(ret, item.GetID())\n\t}\n\treturn ret\n}\n\nfunc moveAttributeViewSortedRows(ordered, selected []string, previousID, nextID string) ([]string, error) {\n\tselectedIDs := map[string]bool{}\n\tfor _, id := range selected {\n\t\tselectedIDs[id] = true\n\t}\n\tif 0 == len(selectedIDs) {\n\t\treturn nil, errors.New(\"no attribute view rows selected\")\n\t}\n\tvar moved, remaining []string\n\tfor _, id := range ordered {\n\t\tif selectedIDs[id] {\n\t\t\tmoved = append(moved, id)\n\t\t} else {\n\t\t\tremaining = append(remaining, id)\n\t\t}\n\t}\n\tif len(moved) != len(selectedIDs) {\n\t\treturn nil, errors.New(\"attribute view rows changed; retry the drag\")\n\t}\n\tif selectedIDs[nextID] || (\"\" == nextID && selectedIDs[previousID]) {\n\t\treturn slices.Clone(ordered), nil\n\t}\n\tindex := 0\n\tif \"\" != nextID {\n\t\tindex = slices.Index(remaining, nextID)","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_row_sort.go#L158-L194","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the drag payload includes at least one selected row ID before invoking the move.","Check the frontend/plugin code that collects selected row IDs for a filtering bug.","If rows may have been deleted concurrently, re-query the view and rebuild the selection, then retry.","Guard the call: if selected.length === 0, skip the API call and show the user a no-op."],"exampleFix":"// before\nsortAttributeViewRow(avID, viewID, [])\n// after\nif (selectedRowIds.length > 0) { sortAttributeViewRow(avID, viewID, selectedRowIds); }","handlingStrategy":"validation","validationCode":"if (!Array.isArray(selected) || selected.filter(id => id && id.trim()).length === 0) {\n  return; // nothing to move, skip the API call\n}","typeGuard":"function hasSelectedRows(sel) {\n  return Array.isArray(sel) && sel.some(id => typeof id === \"string\" && id.length > 0);\n}","tryCatchPattern":null,"preventionTips":["Collect selected row IDs from the live DOM selection right before submitting the drag","Guard plugin calls with a non-empty check on the row ID array"],"tags":["go","attribute-view","drag-and-drop","invalid-argument-value"],"backgroundTag":"empty-required-field","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"}