{"record":{"id":"c19791224a62b295","repo":"siyuan-note/siyuan","slug":"errattributeviewnotfound","errorCode":"ErrAttributeViewNotFound","errorMessage":"attribute view not found","messagePattern":"attribute view not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1383,"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":1365,"sourceCodeEnd":1401,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/av.go#L1365-L1401","documentation":"ErrAttributeViewNotFound is the sentinel error returned whenever a requested attribute view (by ID, or by block binding) cannot be found or the caller lacks access under the current role. The HTTP layer translates publish-access denials into this same message so unauthorized/not-found requests are indistinguishable.","triggerScenarios":"Calling endpoints like getAttributeViewKeysByID or rendering an AV block with an avID/blockID that does not exist; access via publish (read-only) role where CheckAttributeViewAccessableByPublishAccess fails; a stale block ID referencing a deleted database; tests validate this sentinel on access-before-key checks.","commonSituations":"Copy-pasted avID with a typo or from another workspace; the database block was deleted or the .av file removed while clients still reference it; publishing access rules blocking the key; sync leaving a block referencing a missing AV.","solutions":["Verify the avID/blockID exists in the workspace (check for the corresponding .av file under data/storage/av)","Confirm access permissions — for published spaces check publish access rules allow the requested AV","Refresh/re-sync the workspace in case a delete or sync left stale references, then retry","Regenerate the ID from the actual database block in the UI and use that in the API call"],"exampleFix":"// before\nfetchPost(\"/api/av/getAttributeViewKeysByID\", {avID: \"20240101120000-abcdef\"})\n// after\nconst blocks = await fetchPost(\"/api/query/sql\", {stmt: \"SELECT block_id FROM blocks WHERE id='...'\"})\n// derive the real avID from an existing attribute-view block, then call the API","handlingStrategy":"try-catch","validationCode":"const exists = await fetchPost(\"/api/query/sql\", {stmt: \"SELECT id FROM blocks WHERE id='\" + blockID + \"'\"})\nif (!exists || exists.length === 0) throw new Error(\"block/attribute view not found\")","typeGuard":"function isNotFound(resp) { return resp && resp.code === -1 && resp.msg === \"attribute view not found\"; }","tryCatchPattern":"try {\n  return await fetchPost(\"/api/av/getAttributeViewKeysByID\", {avID})\n} catch (e) {\n  if (e.message.includes(\"attribute view not found\")) {\n    // re-resolve the avID from the block, check publish permissions, or resync\n  }\n  throw e\n}","preventionTips":["Resolve avIDs from real database blocks rather than hard-coding them","Check publish/read access rules when serving through published spaces","After deletions or sync, refresh stale references before querying AVs"],"tags":["attribute-view","not-found","permissions"],"backgroundTag":"entity-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"}