{"record":{"id":"5da3439748b66085","repo":"siyuan-note/siyuan","slug":"view-not-found","errorCode":null,"errorMessage":"view not found","messagePattern":"view not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1296,"sourceCode":"\tret = filepath.Join(av, avID+\".json\")\n\tif !gulu.File.IsDir(av) {\n\t\tif err := os.MkdirAll(av, 0755); err != nil {\n\t\t\tlogging.LogErrorf(\"create attribute view dir failed: %s\", err)\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}\n\nfunc GetAttributeViewI18n(key string) string {\n\treturn util.AttrViewLangs[util.Lang][key].(string)\n}\n\nvar (\n\tErrAttributeViewNotFound  = errors.New(\"attribute view not found\")\n\tErrInvalidAttributeViewID = errors.New(\"invalid attribute view id\")\n\tErrInvalidBoxID           = errors.New(\"invalid box id\")\n\tErrViewNotFound           = errors.New(\"view not found\")\n\tErrKeyNotFound            = errors.New(\"key not found\")\n\tErrItemNotFound           = errors.New(\"item not found\")\n\tErrWrongLayoutType        = errors.New(\"wrong layout type\")\n\tErrInvalidColumnAlign     = errors.New(\"invalid column align\")\n\tErrSpecTooNew             = errors.New(\"attribute view spec is too new\")\n\tErrFilterTooDeep          = errors.New(\"filter nesting depth exceeds the maximum allowed\")\n)\n\nconst (\n\tNodeAttrNameAvs        = \"custom-avs\"                 // 用于标记块所属的属性视图，逗号分隔 av id\n\tNodeAttrView           = \"custom-sy-av-view\"          // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443\n\tNodeAttrVisibleViewIDs = \"custom-sy-av-visible-views\" // 用于标记数据库块显示的视图 ID，逗号分隔\n\tNodeAttrViewStaticText = \"custom-sy-av-s-text\"        // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049\n\n\tNodeAttrViewNames = \"av-names\" // 用于临时标记块所属的属性视图名称，空格分隔\n)\n","sourceCodeStart":1278,"sourceCodeEnd":1313,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/av.go#L1278-L1313","documentation":"Sentinel ErrViewNotFound — the most frequently thrown AV error. Returned when a requested view id is absent from the AV's Views list: GetFirstView returns it when there are no views at all; parseAttributeViewByPathInBox returns it when the AV JSON file does not exist; and many model-layer operations return it when the operation targets a view id not present in the loaded AV.","triggerScenarios":"Calling a database operation (setfilter, setsort, setview, getview, render) with a view id that was deleted, never existed, or belongs to a different AV. Also when rendering a brand-new AV that has had no view created yet, or when the AV file itself is missing.","commonSituations":"Client holds stale state after another tab/session deleted or switched the view; a plugin reused a hardcoded view id; race between view deletion and an in-flight operation; AV file removed but block still references it.","solutions":["Refresh the AV's view list (GET /api/av/getAttributeView) and use a current view id.","If the AV has no views, create one before issuing view-scoped operations.","Handle ErrViewNotFound in the client by reloading the database block rather than retrying the stale op.","Confirm the AV file exists (see error 90) when the missing-file overload is suspected."],"exampleFix":"// before\nop := &av.Operation{Action: \"setview\", id: lastViewID}\nerr := model.UpdateAttributeView(op)   // stale lastViewID -> view not found\n\n// after: reload and use a live view id\nattrView, _ := av.ParseAttributeView(avID)\nviewID := attrView.Views[0].ID\nop := &av.Operation{Action: \"setview\", id: viewID}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"view, err := getRenderAttributeViewView(attrView, viewID, \"\", \"\", false)\nif errors.Is(err, av.ErrViewNotFound) {\n    // reload the database block and pick a live view; do not retry the stale id\n    attrView, _ = av.ParseAttributeView(avID)\n    view, err = attrView.GetFirstView()\n}","preventionTips":["Reload the view list before issuing view-scoped operations.","Handle ErrViewNotFound by refreshing state, not by retrying the same id.","Ensure the AV file exists when the missing-file overload is possible."],"tags":["attribute-view","view","not-found","api"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}