siyuan-note/siyuan · error
invalid light theme of inline style [%s]: %w
Error message
invalid light theme of inline style [%s]: %w
What it means
The light theme of an inline style is validated by normalizeInlineStyleTheme, which requires Color and BackgroundColor to be empty or match the #RRGGBB pattern (case-insensitive; the value is lowercased). Any malformed color string in style.Light causes this wrapped error identifying the style by ID.
Source
Thrown at kernel/model/inline_style.go:684
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)
}
if lightColor != darkColor || lightBackground != darkBackground {
return nil, fmt.Errorf("inline style [%s] must use the same fields in light and dark themes", id)
}
ret = append(ret, &InlineStyle{ID: id, Name: name, Hidden: style.Hidden, Light: light, Dark: dark})
}
return ret, nil
}View on GitHub (pinned to 8641553a1f)
Solutions
- Convert the color to 6-digit lowercase-able hex form #RRGGBB (expand #FFF to #FFFFFF, resolve color names to hex).
- Validate all colors client-side against ^#[0-9a-fA-F]{6}$ before submitting the style list.
- Fix the on-disk inline-styles JSON, replacing the offending Light color value.
Example fix
// before
Light: &InlineStyleTheme{Color: "red"}
// after
Light: &InlineStyleTheme{Color: "#ff0000"} Defensive patterns
Strategy: validation
Validate before calling
const hex6 = /^#[0-9a-fA-F]{6}$/; if (theme.Color && !hex6.test(theme.Color)) throw new Error(`bad light color ${theme.Color}`); if (theme.BackgroundColor && !hex6.test(theme.BackgroundColor)) throw new Error('bad light backgroundColor'); Type guard
const isValidColor = (c: string): boolean => c === '' || /^#[0-9a-fA-F]{6}$/.test(c); Try / catch
try { await saveStyles(styles) } catch (e) { if (/invalid light theme/.test(String(e))) { /* surface the style ID and offending color to the user, fix, retry */ } } Prevention
- Use a hex color picker (6-digit output) in any UI writing these values
- Convert 3-digit hex and color names to #RRGGBB before submitting
- Remember only Color/BackgroundColor are allowed — no alpha (use the separate fields if available)
When it happens
Trigger: setInlineStylesData or loadInlineStyles processes an InlineStyle whose Light.Color or Light.BackgroundColor is not a valid #RRGGBB hex value — e.g. "red", "#fff", "ff0000", "#GGHHII", or rgb(...) strings.
Common situations: Users pasting CSS color names or shorthand hex into a custom style config; scripts interpolating colors without formatting; importing styles from other apps that use 3-digit hex or rgb().
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- invalid dark theme of inline style [%s]: %w
- invalid inline styles data: %w
- inline styles count exceeds the %d item limit
- inline style must not be null
- invalid inline style ID [%s]
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/c0c47bb3996a7a1f.
Report an issue: GitHub.