{"record":{"id":"ba1cdf7531edd04c","repo":"siyuan-note/siyuan","slug":"errviewnotfound","errorCode":"ErrViewNotFound","errorMessage":"view not found","messagePattern":"view not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1342,"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\tErrRichTextSpecMismatch   = errors.New(\"attribute view rich text requires storage spec 9\")\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\tNodeAttrContextFilter  = \"custom-sy-av-context-filter\" // 用于保存数据库块独有的上下文筛选配置\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)","sourceCodeStart":1324,"sourceCodeEnd":1360,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/av.go#L1324-L1360","documentation":"ErrViewNotFound means the requested view (tab within an attribute view) could not be located. It is returned when the .av file does not exist on disk (parseAttributeViewByPathInBoxWithOptions), when the AV has no usable first view (GetFirstView), and when an operation references a view ID that isn't present (syncAttrViewTableColWidth, foldAttrViewGroups, getAttrViewOperationView). The API layer maps it to a 'viewNotFound' data payload for the frontend.","triggerScenarios":"Referencing a stale/deleted viewID in attribute-view operations (sort/filter/fold/column width) against an AV whose JSON no longer contains that view; the .av file missing on disk; operating on an AV with zero views.","commonSituations":"A plugin cached a view ID and the view was later deleted or replaced; sync merged AVs and dropped a view; the frontend sent operations for a view from before a database re-creation; a notebook moved without its storage/av directory.","solutions":["Re-fetch the AV's current view list (RenderAttributeView) and use the returned active view ID instead of a cached one","Fall back to GetFirstView / the default view when the stored view ID is absent","Verify the .av file exists in storage/av for the given notebook","Handle the API payload {\"error\":\"viewNotFound\"} in frontend code by reloading the database view"],"exampleFix":"// before\nerr := setAttrViewSort(avID, staleViewID, sorts) // ErrViewNotFound\n// after\nattrView, _ := av.ParseAttributeView(avID)\nviewID := staleViewID\nif _, err := attrView.GetView(viewID); errors.Is(err, av.ErrViewNotFound) {\n    view, _ := attrView.GetFirstView()\n    viewID = view.ID\n}\nerr := setAttrViewSort(avID, viewID, sorts)","handlingStrategy":"fallback","validationCode":"attrView, err := av.ParseAttributeView(avID)\nif err != nil { return err }\nfor _, v := range attrView.Views {\n    if v.ID == viewID { return nil } // requested view exists, safe to proceed\n}\nreturn errors.New(\"view no longer exists; use GetFirstView fallback\")","typeGuard":"func viewExists(attrView *av.AttributeView, viewID string) bool {\n    _, err := attrView.GetView(viewID)\n    return !errors.Is(err, av.ErrViewNotFound)\n}","tryCatchPattern":"err := doViewOp(avID, viewID)\nif errors.Is(err, av.ErrViewNotFound) {\n    if first, ferr := attrView.GetFirstView(); ferr == nil {\n        err = doViewOp(avID, first.ID) // fall back to the first view\n    }\n}","preventionTips":["Always re-fetch the current view ID from RenderAttributeView instead of caching view IDs","Listen for database-change pushes and invalidate cached view references","Handle the API {\"error\":\"viewNotFound\"} payload by reloading the database in the UI"],"tags":["go","attribute-view","not-found","view"],"backgroundTag":"resource-not-found","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}