siyuan-note/siyuan · error
inline style name must not be empty
Error message
inline style name must not be empty
What it means
After trimming, an inline style's Name must be a non-empty string: the name is what users see in the style picker, so nameless styles are rejected during normalization of the style list on save and load.
Source
Thrown at kernel/model/inline_style.go:673
if id == "" && generateIDs {
for {
id = ast.NewNodeID()
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 != ""View on GitHub (pinned to 8641553a1f)
Solutions
- Provide a non-empty, trimmed Name for every inline style before calling the set API.
- Check for whitespace-only names client-side — the code trims first, so " " still fails.
- Fix the on-disk inline-styles JSON by filling in the missing name so loadInlineStyles succeeds.
Example fix
// before
style := &InlineStyle{ID: "20240101120000-abcdefg", Name: "", Light: &InlineStyleTheme{Color: "#ff0000"}, Dark: &InlineStyleTheme{Color: "#ff0000"}}
// after
style := &InlineStyle{ID: "20240101120000-abcdefg", Name: "Red text", Light: &InlineStyleTheme{Color: "#ff0000"}, Dark: &InlineStyleTheme{Color: "#ff0000"}} Defensive patterns
Strategy: validation
Validate before calling
for (const s of styles) { if (!s.Name || !s.Name.trim()) throw new Error(`style ${s.ID} has empty name`); } Type guard
const hasName = (s: InlineStyle): boolean => typeof s.Name === 'string' && s.Name.trim().length > 0;
Try / catch
try { await saveStyles(styles) } catch (e) { if (/name must not be empty/.test(String(e))) { /* prompt for a name or drop the entry, then retry */ } } Prevention
- Require a name in any UI or script that creates styles
- Trim names before saving
- Validate the whole list before one bulk save — one bad entry fails the entire list
When it happens
Trigger: setInlineStylesData receives an InlineStyle with Name "" or only whitespace; loadInlineStyles reads a config where a style entry has an empty name field.
Common situations: Programmatic style creation that sets only colors and forgets the name; a UI round-trip that cleared the name field; JSON entries created by hand missing the name key.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- inline style [%s] must define color or backgroundColor
- Tag cannot be empty
- block write failed: empty block ID
- Conf.Language(126) (localized empty-bookmark-name message)
- invalid inline styles data: %w
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/7509b40e56d5dd48.
Report an issue: GitHub.