{"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":"http","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/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/av/av.go#L1275-L1311","documentation":"Sentinel error av.ErrAttributeViewNotFound (kernel/av/av.go:1293). An attribute view (database) is stored as storage/av/<avID>.json (notebook-level path for encrypted boxes); when a database block references an avID whose storage file cannot be found, rendering (kernel/model/attribute_view_render.go) and API handlers (kernel/api/av.go:1327, surfaced as ret.Msg) return this error. It means the reference exists but the backing data file does not.","triggerScenarios":"Rendering or querying a database block after its storage/av/<id>.json was deleted or never synced; partial sync where the document synced but the av storage file did not; switching workspaces; restoring a cloud snapshot that lacks the av files; manually pruning data/storage/av.","commonSituations":"Multi-device sync races (device A creates the av, device B gets the doc but misses the av file); users hand-cleaning the data directory; interrupted repo sync/checkout; av files excluded by backup tooling.","solutions":["Check whether data/storage/av/<avID>.json (or the notebook-level path for encrypted notebooks) exists on disk","Trigger a full re-sync or re-download the cloud data repo so missing av files are restored","If the av is genuinely gone, remove the stale reference: delete the database block or clear its custom-avs attribute, then recreate the database","Search SQL (blocks with custom-avs containing the id) to find all blocks referencing the missing av before deleting"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check the backing file before rendering or operating on an av reference\navPath := filepath.Join(util.DataDir, \"storage\", \"av\", avID+\".json\")\nif !filelock.IsExist(avPath) {\n    // handle the missing-av case explicitly instead of calling into the kernel\n}","typeGuard":null,"tryCatchPattern":"avView, err := av.ParseAttributeView(avID)\nswitch {\ncase errors.Is(err, av.ErrAttributeViewNotFound):\n    // stale reference: remove the block's custom-avs attr, hide the database block, or prompt the user to re-sync\ncase errors.Is(err, av.ErrInvalidAttributeViewID):\n    // reject the caller-supplied id\ncase err != nil:\n    return err // unexpected\n}","preventionTips":["Always branch on errors.Is(err, av.ErrAttributeViewNotFound) rather than string comparison","After sync restores, verify data/storage/av files exist before rendering database blocks","When deleting attribute views, also strip custom-avs attributes from referencing blocks to avoid stale references","Include storage/av in backups and sync exclusions reviews"],"tags":["attribute-view","database","not-found","sync","siyuan-kernel"],"backgroundTag":"resource-not-found","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}