{"record":{"id":"a86e482cc686b313","repo":"siyuan-note/siyuan","slug":"view-s-not-found","errorCode":null,"errorMessage":"view [%s] not found","messagePattern":"view \\[(.+?)\\] not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view.go","lineNumber":6505,"sourceCode":"\tif err != nil {\n\t\treturn\n\t}\n\terr = av.SaveAttributeView(attrView)\n\treturn\n}\n\nfunc setAttributeViewFieldsHidden(attrView *av.AttributeView, keyID string, viewIDs []string, hidden bool) (err error) {\n\tvar fields []*av.BaseField\n\tseen := map[string]bool{}\n\tfor _, viewID := range viewIDs {\n\t\tif seen[viewID] {\n\t\t\tcontinue\n\t\t}\n\t\tseen[viewID] = true\n\n\t\tview := attrView.GetView(viewID)\n\t\tif nil == view {\n\t\t\treturn fmt.Errorf(\"view [%s] not found\", viewID)\n\t\t}\n\t\tfield := getAttributeViewField(view, keyID)\n\t\tif nil == field {\n\t\t\treturn fmt.Errorf(\"field [%s] not found in view [%s]\", keyID, viewID)\n\t\t}\n\t\tfields = append(fields, field)\n\t}\n\n\tif 1 > len(fields) {\n\t\treturn errors.New(\"view IDs is empty\")\n\t}\n\tfor _, field := range fields {\n\t\tfield.Hidden = hidden\n\t}\n\treturn\n}\n\nfunc getAttributeViewField(view *av.View, keyID string) (ret *av.BaseField) {","sourceCodeStart":6487,"sourceCodeEnd":6523,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/attribute_view.go#L6487-L6523","documentation":"Thrown by setAttributeViewFieldsHidden when one of the viewIDs in the operation does not resolve to a view in the AttributeView (attrView.GetView(viewID) returns nil). Hidden-state changes are applied per view, so every referenced view must exist.","triggerScenarios":"Passing a viewID that was deleted, belongs to another AV, or is malformed; an undo replay referencing a view that a later operation removed; multi-select hidden toggle where one of the selected views no longer exists.","commonSituations":"Stale viewID cached on the client after the user deleted a view; concurrent view deletion during a bulk hide/show operation.","solutions":["Filter the viewIDs list against the AV's current views before sending the hide/show operation.","Refresh view metadata on the client when views are added/removed and invalidate cached viewIDs.","Drop unknown viewIDs silently on the client rather than failing the whole batch."],"exampleFix":"// before\nsetAttributeViewFieldsHidden(attrView, keyID, [viewID1, deletedViewID], true)\n// after\nliveViewIDs := filterExisting(attrView.Views, operation.ViewIDs)\nsetAttributeViewFieldsHidden(attrView, keyID, liveViewIDs, true)","handlingStrategy":"validation","validationCode":"const liveViewIDs = new Set(attrView.views.map(v => v.id))\nconst safeIDs = operation.viewIDs.filter(id => liveViewIDs.has(id))\nif (safeIDs.length === 0) { /* nothing to do; skip the op */ }","typeGuard":null,"tryCatchPattern":"try { await performTx([hideOp]) } catch (e) {\n  if (/view \\[.*\\] not found/.test(String(e.message ?? e))) { reloadViews(avID) } else { throw e }\n}","preventionTips":["Filter viewIDs against the current view list before sending.","Invalidate cached viewIDs when views are added/removed."],"tags":["attribute-view","view-not-found","field-visibility","transaction"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}