{"record":{"id":"b8d2cdd19bd9627b","repo":"siyuan-note/siyuan","slug":"attribute-view-content-is-unavailable","errorCode":null,"errorMessage":"attribute view content is unavailable","messagePattern":"attribute view content is unavailable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":819,"sourceCode":"}\n\nfunc ParseAttributeViewByPath(avJSONPath string) (ret *AttributeView, err error) {\n\treturn parseAttributeViewByPathInBox(avJSONPath, avBoxIDFromPath(avJSONPath))\n}\n\nfunc parseAttributeViewByPathInBox(avJSONPath, boxID string) (ret *AttributeView, err error) {\n\treturn parseAttributeViewByPathInBoxWithOptions(avJSONPath, boxID, true)\n}\n\n// ReadAttributeViewCustomColorUsageByPath 读取属性视图持久化数据中的自定义颜色引用，但不解析派生颜色。\nfunc ReadAttributeViewCustomColorUsageByPath(avJSONPath string) (avID string, indexes []int, err error) {\n\tavID = strings.TrimSuffix(filepath.Base(avJSONPath), filepath.Ext(avJSONPath))\n\tattrView, err := parseAttributeViewByPathInBoxWithOptions(avJSONPath, avBoxIDFromPath(avJSONPath), false)\n\tif err != nil {\n\t\treturn avID, nil, err\n\t}\n\tif attrView == nil {\n\t\treturn avID, nil, errors.New(\"attribute view content is unavailable\")\n\t}\n\treturn avID, attrView.UsedCustomColorIndexes(), nil\n}\n\nfunc parseAttributeViewByPathInBoxWithOptions(avJSONPath, boxID string, resolveColors bool) (ret *AttributeView, err error) {\n\tif !filelock.IsExist(avJSONPath) {\n\t\terr = ErrViewNotFound\n\t\treturn\n\t}\n\trelease, lockErr := holdAVBoxReadLock(boxID)\n\tif lockErr != nil {\n\t\treturn nil, lockErr\n\t}\n\tdefer release()\n\n\tavID := filepath.Base(avJSONPath)\n\tavID = strings.TrimSuffix(avID, filepath.Ext(avID))\n","sourceCodeStart":801,"sourceCodeEnd":837,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/av.go#L801-L837","documentation":"After locating an attribute view JSON file by path, the loader parses it and expects a valid AttributeView object. If parsing succeeds structurally but returns a nil attribute view, the code treats the content as unavailable and raises this error instead of dereferencing nil. It guards callers from a nil object that would otherwise panic.","triggerScenarios":"parseAttributeViewByPathInBoxWithOptions returning (nil, nil) — e.g. an .av file that exists but yields no parsed content through the options path; passing a path whose base name lacks a valid AV id; edge cases with empty/corrupt .av content.","commonSituations":"Pointing custom tooling at a .av path that is empty or truncated; races where the file is being rewritten mid-read producing a degenerate parse; calling UsedCustomColorIndexes helpers on non-AV files.","solutions":["Verify the .av file exists and contains a valid attribute view JSON (with id, keys, views)","Re-check the path: it must point to an actual .av file, not a directory or unrelated file","Retry after concurrent writes complete; if the file is empty, restore it from sync/history or re-save the AV from the UI","If the AV is genuinely broken, recreate the database block or restore from snapshot/history"],"exampleFix":"// before\navID, colors, err := av.UsedCustomColorIndexesByPath(path) // err: attribute view content is unavailable\n// after\nif _, statErr := os.Stat(path); statErr == nil {\n  if data, _ := os.ReadFile(path); len(bytes.TrimSpace(data)) == 0 {\n    // restore or resave the .av file before retrying\n  }\n}","handlingStrategy":"fallback","validationCode":"const data = await kernelReadFile(avPath)\nif (!data || !data.trim().startsWith(\"{\")) throw new Error(\".av file is empty or not JSON: \" + avPath)","typeGuard":"function looksLikeAV(obj) { return obj && typeof obj.id === \"string\" && Array.isArray(obj.keys); }","tryCatchPattern":"try {\n  avID, colors, err = avLib.ColorIndexesByPath(path)\n} catch (e) {\n  if (strings.Contains(err.Error(), \"content is unavailable\")) {\n    // restore .av from history/snapshot, then retry once\n  } else { return err }\n}","preventionTips":["Confirm the .av file is non-empty and valid JSON before pointing tooling at it","Restore empty/corrupt .av files from sync snapshots or history before use","Never rename or hand-edit .av files in ways that break the id/filename pairing"],"tags":["attribute-view","nil","file-corruption"],"backgroundTag":"resource-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"}