{"record":{"id":"f42f9f0b2b5230ae","repo":"siyuan-note/siyuan","slug":"attribute-view-not-found","errorCode":null,"errorMessage":"attribute view not found","messagePattern":"attribute view not found","errorType":"error_code","errorClass":"ErrAttributeViewNotFound","httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1293,"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\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\" // 用于临时标记块所属的属性视图名称，空格分隔","sourceCodeStart":1275,"sourceCodeEnd":1311,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/av.go#L1275-L1311","documentation":"Sentinel ErrAttributeViewNotFound. Returned by model/attribute_view_render.go when ParseAttributeView yields nil for a requested avID during content rendering, export, or attribute lookups (multiple sites around lines 435, 1057, 1100, 1141, 1197, 1223). It means the AV JSON file does not exist on disk or could not be located for the given id.","triggerScenarios":"Requesting render/content for an avID that was never created, was deleted, whose .json was removed manually, or that lives in a notebook not currently mounted. Also when a block references an avID via custom-avs that no longer resolves.","commonSituations":"Stale block attribute referencing a deleted database; data loss after a failed sync; manual deletion of files under data/storage/av/; referencing an AV from an unmounted/encrypted notebook without the key.","solutions":["Verify the avID exists: GET /api/av/getAttributeView with the id and check for the same error.","If the AV was deleted, remove the dangling reference from the block's custom-avs attribute.","If it should exist, check data/storage/av/<avID>.json is present and the notebook is mounted.","For encrypted notebooks, confirm the notebook is unlocked so the AV can be decrypted and located."],"exampleFix":"// before\nav, err := av.ParseAttributeView(avID)\nrender(av)\n\n// after: handle the not-found sentinel explicitly\nav, err := av.ParseAttributeView(avID)\nif errors.Is(err, av.ErrAttributeViewNotFound) || av == nil {\n    // drop the stale reference instead of rendering a nil view\n    clearBlockAVRef(block, avID)\n    return\n}","handlingStrategy":"validation","validationCode":"// Confirm the AV exists before rendering\nif !av.IsAttributeViewExist(avID) {\n    return // or clear the block's custom-avs reference\n}","typeGuard":null,"tryCatchPattern":"avView, err := av.ParseAttributeView(avID)\nif errors.Is(err, av.ErrAttributeViewNotFound) || avView == nil {\n    // stale reference; do not render\n    return\n}","preventionTips":["Remove block custom-avs references when their AV is deleted.","For encrypted notebooks, unlock before rendering AV-backed blocks.","Confirm data/storage/av/<avID>.json exists after restores/syncs."],"tags":["attribute-view","not-found","render"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}