siyuan-note/siyuan · error

inline style name exceeds the

Error message

inline style name exceeds the %d character limit

What it means

Inline style names are capped at maxInlineStyleNameRunes (64) runes (not bytes), so CJK and emoji count fairly. normalizeInlineStyles measures the trimmed name with utf8.RuneCountInString and rejects the save/load when it exceeds the limit, keeping picker labels and the styles JSON tidy.

Solutions

  1. Shorten the style name to 64 runes or fewer before saving
  2. Truncate client-side: for _, r := range name { if i >= 64 { break }; ... } counting runes, not bytes
  3. Trim redundant whitespace first (the check runs on the trimmed value), which may bring the count under the limit
  4. If loading fails, edit the config JSON to shorten the offending name

Example fix

// before
name := "Very long style name generated from selected text that goes on and on and clearly exceeds sixty-four runes in total"
// after
name := truncateRunes(strings.TrimSpace(longName), 64) // max 64 runes
Defensive patterns

Strategy: validation

Validate before calling

func namesWithinLimit(styles []*InlineStyle, max int) bool {
	for _, s := range styles {
		if utf8.RuneCountInString(strings.TrimSpace(s.Name)) > max {
			return false
		}
	}
	return true // max = 64 (maxInlineStyleNameRunes)
}

Try / catch

if err != nil && strings.Contains(err.Error(), "character limit") {
	// truncate names to 64 runes and retry once
}

Prevention

When it happens

Trigger: Calling model.SetInlineStyles / model.SetInlineStylesData with a style whose trimmed Name is longer than 64 runes; pasting long text (a sentence, URL, or Markdown snippet) into the style name; loading a config whose entry has an oversized name from an external writer that never enforced the cap.

Common situations: Using an AI/clipboard tool that pastes a long description as the style name; a script generating names from block content; international text where a 64-byte check elsewhere misleads authors into thinking longer CJK names fit.

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@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/48de3d8c54f49ad7. Report an issue: GitHub.

Appendix: 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 9f775e8a12)