siyuan-note/siyuan · error

inline style name exceeds the %d character limit

Error message

inline style name exceeds the %d character limit

What it means

Inline style names are limited to maxInlineStyleNameRunes (64) Unicode runes. The check counts runes (not bytes), so multibyte characters count once each; exceeding the limit aborts the save/load of the whole style list.

Source

Thrown at kernel/model/inline_style.go:676

				if _, exists := ids[id]; !exists {
					break
				}
			}
		}
		if !ast.IsNodeIDPattern(id) {
			return nil, fmt.Errorf("invalid inline style ID [%s]", id)
		}
		if _, exists := ids[id]; exists {
			return nil, fmt.Errorf("duplicate inline style ID [%s]", id)
		}
		ids[id] = struct{}{}

		name := strings.TrimSpace(style.Name)
		if name == "" {
			return nil, errors.New("inline style name must not be empty")
		}
		if maxInlineStyleNameRunes < utf8.RuneCountInString(name) {
			return nil, fmt.Errorf("inline style name exceeds the %d character limit", maxInlineStyleNameRunes)
		}
		if style.Light == nil || style.Dark == nil {
			return nil, fmt.Errorf("inline style [%s] must define light and dark themes", id)
		}

		light, err := normalizeInlineStyleTheme(style.Light)
		if err != nil {
			return nil, fmt.Errorf("invalid light theme of inline style [%s]: %w", id, err)
		}
		dark, err := normalizeInlineStyleTheme(style.Dark)
		if err != nil {
			return nil, fmt.Errorf("invalid dark theme of inline style [%s]: %w", id, err)
		}
		lightColor, lightBackground := light.Color != "", light.BackgroundColor != ""
		darkColor, darkBackground := dark.Color != "", dark.BackgroundColor != ""
		if !lightColor && !lightBackground {
			return nil, fmt.Errorf("inline style [%s] must define color or backgroundColor", id)
		}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Shorten the style name to 64 runes or fewer (trim on the client before saving).
  2. Truncate programmatically: cut the name to utf8.RuneCountInString(name) <= 64, on a rune boundary.
  3. Move the descriptive text into a comment or separate field and keep the name a short label.

Example fix

// before
style.Name = strings.Repeat("very long descriptive name ", 10) // > 64 runes
// after
name := []rune(rawName)
if len(name) > 64 {
    name = name[:64]
}
style.Name = string(name)
Defensive patterns

Strategy: validation

Validate before calling

for (const s of styles) { if ([...s.Name.trim()].length > 64) throw new Error(`style ${s.ID} name exceeds 64 characters`); }

Try / catch

try { await saveStyles(styles) } catch (e) { if (/name exceeds/.test(String(e))) { styles = styles.map(s => ({...s, Name: [...s.Name].slice(0, 64).join('')})); /* retry */ } }

Prevention

When it happens

Trigger: setInlineStylesData receives an InlineStyle whose trimmed Name is longer than 64 runes; loadInlineStyles reads a config file containing an over-long style name (e.g. pasted descriptive text as the style name).

Common situations: Pasting a long CSS description or sentence into the style-name field; scripts generating names from style content; CJK names — although counted per rune, long Chinese names can still pass 64 runes.

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


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/48de3d8c54f49ad7. Report an issue: GitHub.