siyuan-note/siyuan · error
invalid dark theme of inline style
Error message
invalid dark theme of inline style [%s]: %w
What it means
Identical to error 1586 but for the Dark theme: normalizeInlineStyleTheme validates Dark.Color and Dark.BackgroundColor against the #RRGGBB pattern, and any malformed value aborts the whole save/load with this wrapped message naming the style ID.
Solutions
- Rewrite the dark theme color as strict #RRGGBB lowercase hex
- Apply the same conversion routine to both themes so neither drifts out of format
- Leave the field as "" if the dark theme should omit that property (but see error 1589: field usage must match light)
- Validate both colors with ^#[0-9a-f]{6}$ before calling the API
Example fix
// before
Dark: &InlineStyleTheme{BackgroundColor: "rgba(0,0,0,0.2)"}
// -> invalid dark theme of inline style [id]: invalid backgroundColor: ...
// after
Dark: &InlineStyleTheme{BackgroundColor: "#000000"} // opacity via the style's other means, not alpha Defensive patterns
Strategy: validation
Validate before calling
var colorRe = regexp.MustCompile(`^#[0-9a-f]{6}$`)
func validDarkTheme(t *InlineStyleTheme) bool {
c := strings.ToLower(strings.TrimSpace(t.Color))
b := strings.ToLower(strings.TrimSpace(t.BackgroundColor))
return (c == "" || colorRe.MatchString(c)) && (b == "" || colorRe.MatchString(b))
} Type guard
func isHexColor(s string) bool {
m, _ := regexp.MatchString(`^#[0-9a-fA-F]{6}$`, strings.TrimSpace(s))
return m
} Try / catch
if _, _, err := model.SetInlineStylesData(cfg); err != nil {
if strings.Contains(err.Error(), "invalid dark theme") {
// fix Dark.Color / Dark.BackgroundColor to #RRGGBB and retry
}
return err
} Prevention
- Apply the same color converter to dark values — do not special-case dark colors
- Reject rgba()/alpha values at input time since #RRGGBB has no alpha channel
- Round-trip-test theme exports through the validator before writing config
When it happens
Trigger: Calling model.SetInlineStyles / model.SetInlineStylesData with Dark.Color or Dark.BackgroundColor set to a non-#RRGGBB value (named color, rgba(), 3-digit hex, missing #, 8-digit hex); loading a config whose dark-theme colors were written by an external tool in CSS syntax.
Common situations: Designers hand-picking a darker variant in CSS notation (e.g. "rgba(0,0,0,.5)") for the dark theme; scripts converting theme palettes that emit different formats for dark colors; stale entries from an older config version.
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
- inline style [ ] must define color or backgroundColor
- inline style [ ] must define light and dark themes
- inline style [ ] must use the same fields in light and dark…
- invalid light theme of inline style
- all asset mappings failed
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/0c4f45e155fd10ed.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:688
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
}
func normalizeInlineStyleBuiltin(builtin *InlineStyleBuiltin) (ret *InlineStyleBuiltin, err error) {
ret = newEmptyInlineStyleBuiltin()
if builtin == nil {View on GitHub (pinned to 9f775e8a12)