{"record":{"id":"c19791224a62b295","repo":"siyuan-note/siyuan","slug":"errattributeviewnotfound","errorCode":"ErrAttributeViewNotFound","errorMessage":"attribute view not found","messagePattern":"attribute view not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1339,"sourceCode":"\t}\n\n\tav := filepath.Join(util.DataDir, \"storage\", \"av\")\n\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","sourceCodeStart":1321,"sourceCodeEnd":1357,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/av.go#L1321-L1357","documentation":"ErrAttributeViewNotFound is the package-level sentinel of the av package meaning the requested attribute view (database) does not exist or is not accessible to the caller. Public API handlers also reuse its message as the response for read-only/publish contexts where AV access is denied, so it doubles as an access-denied marker in those HTTP endpoints.","triggerScenarios":"Calling getAttributeViewKeysByID, RenderAttributeViewWithTarget, or ResolveRepoSnapshotAttributeViewBoxID with an avID that has no .av file; HTTP API calls to /api/av/* where model.CheckAttributeView(Access)ableByPublishAccess fails (publish/read-only mode without access) and ret.Msg is set to this error's text.","commonSituations":"A plugin or script referencing a deleted database; a hardcoded avID from another workspace; accessing a published/read-only kernel endpoint for an AV the publish access rules don't allow; snapshot restore where the AV JSON is missing.","solutions":["Verify the avID exists: check for <doc-id>.av under the notebook's storage/av directory","Re-obtain the avID from the block's attributes (custom-av) instead of hardcoding it","If hitting the publish/read-only API, grant the AV access in publish access settings or call with proper authorization","Recreate the attribute view if it was intentionally deleted"],"exampleFix":"// before\nkeys, err := av.GetAttributeViewKeysByID(avID) // ErrAttributeViewNotFound\n// after\nif _, statErr := os.Stat(filepath.Join(dataDir, boxID, \"storage\", \"av\", avID+\".av\")); statErr != nil {\n    return nil, fmt.Errorf(\"av %s does not exist in notebook %s\", avID, boxID)\n}\nkeys, err := av.GetAttributeViewKeysByID(avID)","handlingStrategy":"validation","validationCode":"if !ast.IsNodeIDPattern(avID) || !filelock.IsExist(filepath.Join(dataDir, boxID, \"storage\", \"av\", avID+\".av\")) {\n    return errors.New(\"attribute view does not exist\")\n}","typeGuard":"func avExists(dataDir, boxID, avID string) bool {\n    return ast.IsNodeIDPattern(avID) && filelock.IsExist(filepath.Join(dataDir, boxID, \"storage\", \"av\", avID+\".av\"))\n}","tryCatchPattern":"keys, err := av.GetAttributeViewKeysByID(avID)\nif errors.Is(err, av.ErrAttributeViewNotFound) {\n    http.Error(w, \"database not found\", http.StatusNotFound)\n    return\n}","preventionTips":["Always fetch avIDs dynamically from the block's attributes, never hardcode them","Check publish access rules before calling read-only endpoints on an AV","After deleting a database, clean up plugins/scripts that reference its avID"],"tags":["go","attribute-view","not-found","access-control"],"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"}