siyuan-note/siyuan · error
inline styles count exceeds the %d item limit
Error message
inline styles count exceeds the %d item limit
What it means
normalizeInlineStyles enforces maxInlineStyles, the maximum number of custom inline styles allowed. When the input slice exceeds this count, normalization aborts with this error; it is reached both when loading an oversized file and when saving (setInlineStylesData) a style list that is too large.
Source
Thrown at kernel/model/inline_style.go:645
hidden := map[int]struct{}{}
for _, index := range styles.Builtin.Hidden.AV {
hidden[index] = struct{}{}
}
ret := make([]int, 0, neutralAVColorIndex)
for index := minBuiltinColorIndex; index <= neutralAVColorIndex; index++ {
if _, ok := hidden[index]; !ok {
ret = append(ret, index)
}
}
if len(ret) == 0 {
return []int{neutralAVColorIndex}
}
return ret
}
func normalizeInlineStyles(styles []*InlineStyle, generateIDs bool) (ret []*InlineStyle, err error) {
if maxInlineStyles < len(styles) {
return nil, fmt.Errorf("inline styles count exceeds the %d item limit", maxInlineStyles)
}
ret = make([]*InlineStyle, 0, len(styles))
ids := make(map[string]struct{}, len(styles))
for _, style := range styles {
if style == nil {
return nil, errors.New("inline style must not be null")
}
id := strings.TrimSpace(style.ID)
if id == "" && generateIDs {
for {
id = ast.NewNodeID()
if _, exists := ids[id]; !exists {
break
}
}
}
if !ast.IsNodeIDPattern(id) {View on GitHub (pinned to 8641553a1f)
Solutions
- Prune the style list below maxInlineStyles before saving (remove unused/duplicate styles in the app UI)
- Deduplicate entries with identical style payloads; sync merges often create exact duplicates
- Split usage across built-in styles instead of creating a custom style per variant
- If the limit is genuinely too small for the use case, raise maxInlineStyles in code (developer change)
Example fix
// before: saving an oversized list fails
styles := loadAllImportedStyles() // len > maxInlineStyles
_, err := setInlineStylesData(styles)
// after: cap before saving
if len(styles) > maxInlineStyles {
styles = styles[:maxInlineStyles]
}
_, err := setInlineStylesData(styles) Defensive patterns
Strategy: validation
Validate before calling
function withinStyleLimit(styles, max) {
return Array.isArray(styles) && styles.length <= max;
} Prevention
- Cap imported style lists to the limit before saving
- Deduplicate identical styles created by repeated sync merges
- Prefer built-in styles over creating a custom style for every color variant
When it happens
Trigger: Calling SetInlineStyles/SetInlineStylesData with more styles than maxInlineStyles, or loading an inline-styles file whose styles array already exceeds the cap.
Common situations: Importing a large style collection from another workspace or export file, plugins/scripts bulk-adding styles in a loop, or repeated sync merges duplicating style entries until the cap is hit.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- invalid inline styles data: %w
- inline style must not be null
- invalid inline style ID [%s]
- duplicate inline style ID [%s]
- inline style name must not be empty
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/ce27516e5074886c.
Report an issue: GitHub.