{"record":{"id":"75f46c191af8e33f","repo":"siyuan-note/siyuan","slug":"attribute-view-item-s-not-found","errorCode":null,"errorMessage":"attribute view item [%s] not found","messagePattern":"attribute view item \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_render.go","lineNumber":396,"sourceCode":"\t\t\tret[keyValues.Key.Rollup.KeyID] = struct{}{}\n\t\t}\n\t}\n\treturn\n}\n\nfunc getAttributeViewPasteRowsFromTable(table *av.Table, startItemID string, count int) (rows []*av.TableRow, err error) {\n\tif count < 1 {\n\t\treturn nil, fmt.Errorf(\"invalid paste row count [%d]\", count)\n\t}\n\tstart := -1\n\tfor i, row := range table.Rows {\n\t\tif row.ID == startItemID {\n\t\t\tstart = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif 0 > start {\n\t\treturn nil, fmt.Errorf(\"attribute view item [%s] not found\", startItemID)\n\t}\n\tend := start + min(count, len(table.Rows)-start)\n\treturn table.Rows[start:end], nil\n}\n\nfunc RenderAttributeViewWithTarget(blockID, avID, viewID, query string, page, pageSize int, groupPaging map[string]any, initialLayout av.LayoutType, createIfNotExist, ignoreRows bool, targetItemID, targetGroupID string) (viewable av.Viewable, attrView *av.AttributeView, target *AttributeViewRenderTarget, err error) {\n\tif !ast.IsNodeIDPattern(avID) {\n\t\terr = ErrInvalidID\n\t\treturn\n\t}\n\n\twaitForSyncingStorages()\n\n\tavBoxID, exactBox, resolveErr := resolveAttributeViewCarrierBoxID(blockID)\n\tif nil != resolveErr {\n\t\terr = resolveErr\n\t\treturn\n\t}","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_render.go#L378-L414","documentation":"After validating count, getAttributeViewPasteRowsFromTable scans table.Rows for the row whose ID equals startItemID to use as the paste anchor. If no row matches (start remains -1), the anchor item no longer exists in this table and this error is returned.","triggerScenarios":"Calling GetAttributeViewPasteRows with a startItemID that was deleted, or that belongs to a different view/group than the one being searched.","commonSituations":"Concurrent editing removed the anchor row between UI interaction and API call; startItemID taken from a stale selection; anchoring on a row in another group of a grouped view.","solutions":["Re-fetch the current rows and re-select a valid startItemID before pasting","Check the row still exists (matching row.ID) before issuing the paste request","Fall back to appending at the end of the table when the anchor cannot be found, if product logic allows"],"exampleFix":"// before\nconst startItemID = staleSelection.rowID\n// after\nif (!table.Rows.some(r => r.id === staleSelection.rowID)) { return fallbackAppendAtEnd() }\nconst startItemID = staleSelection.rowID","handlingStrategy":"validation","validationCode":"const anchor = table.rows.find(r => r.id === startItemID)\nif (!anchor) { throw new Error(`anchor row ${startItemID} no longer exists`) }","typeGuard":null,"tryCatchPattern":"rows, err := getAttributeViewPasteRowsFromTable(table, startItemID, count)\nif err != nil && strings.Contains(err.Error(), \"attribute view item [\") {\n    rows, err = appendAtTableEnd(table, pastedData) // fallback\n}","preventionTips":["Re-read current rows immediately before pasting instead of using stale selections","Handle concurrent edits that delete the anchor row","Scope startItemID to the same group being queried"],"tags":["not-found","paste","concurrency"],"backgroundTag":"record-not-found","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"}