siyuan-note/siyuan · error
write inline styles failed
Error message
write inline styles failed: %w
What it means
After the directory exists, the styles JSON is persisted with filelock.WriteFile. Any write failure (disk full, permission denied, I/O error, lock contention) aborts the update, wrapped as this error, leaving the old file intact.
Solutions
- Free disk space and verify the volume is writable, then retry the operation.
- Fix permissions on the storage file/directory for the kernel process user (chmod/chown).
- Stop competing processes (second SiYuan instance, sync/backup clients) holding the file lock and retry.
Defensive patterns
Strategy: retry
Validate before calling
// Pre-flight: disk free space and write permission on the storage directory // unix.Access(dirPath, unix.W_OK)
Try / catch
if err != nil && strings.Contains(err.Error(), "write inline styles failed") {
// free disk space / fix locks, wait briefly, then retry with backoff
} Prevention
- Monitor disk free space on the workspace volume
- Stop competing SiYuan instances and file-locking sync tools before large palette imports
- Verify write permissions after OS or user changes
When it happens
Trigger: setInlineStylesData calling filelock.WriteFile on the styles path when the filesystem rejects the write — disk full, no write permission, file held by another process, or underlying I/O failure.
Common situations: Full disk during a large palette import; workspace folder owned by another user; backup/sync tools locking the storage file; failing disk sectors.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- read inline styles failed
- attribute view custom color
- builtin color must not be null
- builtin style must not be null
- cannot read pinned document
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/039f6d2c6e36379d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:299
if maxInlineStylesFileSize < len(data) {
return nil, false, fmt.Errorf("inline styles file exceeds the %d byte limit", maxInlineStylesFileSize)
}
dataPath := inlineStylesPath()
oldData, readErr := filelock.ReadFile(dataPath)
if readErr != nil && !os.IsNotExist(readErr) {
return nil, false, fmt.Errorf("read inline styles failed: %w", readErr)
}
if bytes.Equal(oldData, data) {
cacheWorkspaceAVPalette(ret.AV)
return ret, false, nil
}
if err = os.MkdirAll(filepath.Dir(dataPath), 0755); err != nil {
return nil, false, fmt.Errorf("create inline styles directory failed: %w", err)
}
if err = filelock.WriteFile(dataPath, data); err != nil {
return nil, false, fmt.Errorf("write inline styles failed: %w", err)
}
cacheWorkspaceAVPalette(ret.AV)
IncSync()
for _, avID := range sortedAttributeViewUsageIDs(customColorUsage) {
indexes := customColorUsage[avID]
if intersectsCustomColorIndexes(indexes, changedCustomColorIndexes) {
pushReloadAttrView(avID)
}
}
return ret, true, nil
}
func inlineStylesPath() string {
return filepath.Join(util.DataDir, "storage", "inline-styles.json")
}
func cacheWorkspaceAVPalette(palette *InlineStyleAV) {
workspaceAVPaletteCache, _ = normalizeInlineStyleAV(palette, false)View on GitHub (pinned to 9f775e8a12)