siyuan-note/siyuan · error
inline styles file exceeds the %d byte limit
Error message
inline styles file exceeds the %d byte limit
What it means
Before writing, the serialized inline-styles JSON is size-checked against maxInlineStylesFileSize to keep the single workspace styles file small and cheap to sync. When the marshaled payload exceeds the limit, the update is rejected with the byte limit included in the message. No partial write occurs.
Source
Thrown at kernel/model/inline_style.go:282
if err != nil {
return nil, false, err
}
for _, avID := range sortedAttributeViewUsageIDs(customColorUsage) {
indexes := customColorUsage[avID]
for index := range removedIndexes {
if _, used := indexes[index]; used {
return nil, false, fmt.Errorf("attribute view custom color [%d] is still in use by attribute view [%s]",
index, avID)
}
}
}
}
data, err := gulu.JSON.MarshalIndentJSON(ret, "", " ")
if err != nil {
return nil, false, fmt.Errorf("marshal inline styles failed: %w", err)
}
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)
}View on GitHub (pinned to 8641553a1f)
Solutions
- Check maxInlineStylesFileSize in kernel/model/inline_style.go and trim styles.Styles to fit under it
- Remove unused custom color entries (only those not reported by workspaceAttributeViewCustomColorUsage)
- Split colors across attribute views using default palette entries instead of many custom colors
- Verify the payload is not accidentally duplicated (e.g. merging current styles into the new payload twice)
Example fix
// before styles.Styles = allHistoryColors // hundreds of entries, file exceeds limit // after usage, _ := workspaceAttributeViewCustomColorUsage(true) styles.Styles = pruneUnusedColors(allHistoryColors, usage) // keep only referenced colors
Defensive patterns
Strategy: validation
Validate before calling
data, _ := json.MarshalIndent(styles, "", " ")
if len(data) > model.MaxInlineStylesFileSize {
return fmt.Errorf("styles payload %d bytes exceeds limit", len(data))
} Try / catch
_, _, err := model.SetInlineStyles(styles)
if err != nil && strings.Contains(err.Error(), "byte limit") {
// prune unused colors and retry with a smaller payload
} Prevention
- Prune unused custom colors periodically using the usage map
- Do not bulk-import unbounded palette exports into a workspace
- Estimate payload size before writing when programmatically generating styles
When it happens
Trigger: Adding a very large number of custom color entries to the workspace palette; accumulating many per-AV usage mappings over time; a malicious or buggy bulk import that inflates styles.Styles.
Common situations: Long-lived workspaces where old palettes are never pruned; scripted palette generation with generated IDs; importing palette data exported from a much larger workspace.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- template document tree output exceeds %d bytes
- template call depth exceeds %d
- skill resource exceeds the %d byte limit: %s/%s
- view not found
- key not found
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/94defde80b6107df.
Report an issue: GitHub.