siyuan-note/siyuan · error
attribute view content is unavailable
Error message
attribute view content is unavailable
What it means
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.
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
Example fix
// before
avID, colors, err := av.UsedCustomColorIndexesByPath(path) // err: attribute view content is unavailable
// after
if _, statErr := os.Stat(path); statErr == nil {
if data, _ := os.ReadFile(path); len(bytes.TrimSpace(data)) == 0 {
// restore or resave the .av file before retrying
}
} Defensive patterns
Strategy: fallback
Validate before calling
const data = await kernelReadFile(avPath)
if (!data || !data.trim().startsWith("{")) throw new Error(".av file is empty or not JSON: " + avPath) Type guard
function looksLikeAV(obj) { return obj && typeof obj.id === "string" && Array.isArray(obj.keys); } Try / catch
try {
avID, colors, err = avLib.ColorIndexesByPath(path)
} catch (e) {
if (strings.Contains(err.Error(), "content is unavailable")) {
// restore .av from history/snapshot, then retry once
} else { return err }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- clone attribute view
- [/api/av/batchSetAttributeViewBlockAttrs] parameter [rowID]…
- at least one visible view is required
- attribute view custom color
- attribute view custom color
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/b8d2cdd19bd9627b.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/av.go:819
}
func ParseAttributeViewByPath(avJSONPath string) (ret *AttributeView, err error) {
return parseAttributeViewByPathInBox(avJSONPath, avBoxIDFromPath(avJSONPath))
}
func parseAttributeViewByPathInBox(avJSONPath, boxID string) (ret *AttributeView, err error) {
return parseAttributeViewByPathInBoxWithOptions(avJSONPath, boxID, true)
}
// ReadAttributeViewCustomColorUsageByPath 读取属性视图持久化数据中的自定义颜色引用,但不解析派生颜色。
func ReadAttributeViewCustomColorUsageByPath(avJSONPath string) (avID string, indexes []int, err error) {
avID = strings.TrimSuffix(filepath.Base(avJSONPath), filepath.Ext(avJSONPath))
attrView, err := parseAttributeViewByPathInBoxWithOptions(avJSONPath, avBoxIDFromPath(avJSONPath), false)
if err != nil {
return avID, nil, err
}
if attrView == nil {
return avID, nil, errors.New("attribute view content is unavailable")
}
return avID, attrView.UsedCustomColorIndexes(), nil
}
func parseAttributeViewByPathInBoxWithOptions(avJSONPath, boxID string, resolveColors bool) (ret *AttributeView, err error) {
if !filelock.IsExist(avJSONPath) {
err = ErrViewNotFound
return
}
release, lockErr := holdAVBoxReadLock(boxID)
if lockErr != nil {
return nil, lockErr
}
defer release()
avID := filepath.Base(avJSONPath)
avID = strings.TrimSuffix(avID, filepath.Ext(avID))
View on GitHub (pinned to 9f775e8a12)