siyuan-note/siyuan · error
read attribute view custom color usage
Error message
read attribute view custom color usage [%s] failed: %w
What it means
While collecting which custom colors are used by each attribute view, av.ReadAttributeViewCustomColorUsageByPath failed for one .json attribute view file. The kernel wraps the AV ID and underlying error. In strict mode this aborts the whole custom color usage refresh; otherwise it is logged and the file is skipped.
Solutions
- Inspect the wrapped cause for the specific av file and validate its JSON structure
- Fix permissions on <workspace>/data/**/storage/av/*.json
- Restore the corrupt .json attribute view file from backup or sync history, then retry
Example fix
// before (strict abort)
return nil, fmt.Errorf("read attribute view custom color usage [%s] failed: %w", avID, readErr)
// after: call with strict=false so bad files are skipped
usage, err := workspaceAttributeViewCustomColorUsage(false) Defensive patterns
Strategy: try-catch
Validate before calling
const raw = fs.readFileSync(avPath, 'utf8'); JSON.parse(raw); // throws before the API call if the av file is corrupt
Type guard
const isAvJson = (s) => { try { const o = JSON.parse(s); return typeof o === 'object' && o !== null; } catch { return false; } }; Try / catch
try {
await fetchPost('/api/attr/setInlineStylesData', payload);
} catch (e) {
if (String(e).includes('read attribute view custom color usage')) {
logging.warn(`corrupt attribute view ignored: ${e}`);
}
} Prevention
- Do not hand-edit .json files under storage/av
- Verify attribute view JSON integrity after interrupted syncs
- Keep storage/av files readable by the kernel process
When it happens
Trigger: setInlineStylesData iterating a corrupt, unreadable, or malformed .json file under data/storage/av or <notebook>/storage/av when strict=true.
Common situations: Partially written or corrupted attribute view JSON from an interrupted sync, permission-restricted av files, hand-edited JSON with invalid structure.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- decode existing session data failed
- invalid attribute view JSON
- Invalid attribute view rich text style entity
- invalid document JSON
- list notebook attribute views
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/f375c33190848c46.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:437
}
for _, entry := range entries {
if !entry.IsDir() || !ast.IsNodeIDPattern(entry.Name()) {
continue
}
if err = appendPaths(filepath.Join(util.DataDir, entry.Name(), "storage", "av")); err != nil {
if strict {
return nil, fmt.Errorf("list notebook attribute views [%s] failed: %w", entry.Name(), err)
}
logging.LogWarnf("list notebook attribute views [%s] for custom color refresh failed: %s",
entry.Name(), err)
}
}
sort.Strings(paths)
for _, path := range paths {
avID, indexes, readErr := av.ReadAttributeViewCustomColorUsageByPath(path)
if readErr != nil {
if strict {
return nil, fmt.Errorf("read attribute view custom color usage [%s] failed: %w", avID, readErr)
}
logging.LogWarnf("read attribute view custom color usage [%s] for refresh failed: %s", avID, readErr)
continue
}
used := ret[avID]
if used == nil {
used = map[int]struct{}{}
ret[avID] = used
}
for _, index := range indexes {
used[index] = struct{}{}
}
}
return ret, nil
}
func isInlineStylesRepoPath(filePath string) bool {
return filePath == inlineStylesRepoPathView on GitHub (pinned to 9f775e8a12)