siyuan-note/siyuan · error
inline style [ ] must define color or backgroundColor
Error message
inline style [%s] must define color or backgroundColor
What it means
A theme pair where the light theme has neither Color nor BackgroundColor (both empty after normalization) is inert — it would render nothing. normalizeInlineStyles rejects such a style and aborts the whole save/load, requiring at least one visual property.
Solutions
- Set at least Color or BackgroundColor on the light theme (and mirror the same field on dark)
- If the style is meant to be disabled, remove it from the list entirely rather than emptying its light theme
- Validate the light theme has one non-empty color field before calling the API
- Repair the config JSON so the entry has a real light color
Example fix
// before
Light: &InlineStyleTheme{}, Dark: &InlineStyleTheme{Color: "#eee"}
// -> inline style [id] must define color or backgroundColor
// after
Light: &InlineStyleTheme{Color: "#111"}, Dark: &InlineStyleTheme{Color: "#eee"} Defensive patterns
Strategy: validation
Validate before calling
func lightThemeHasVisual(t *InlineStyleTheme) bool {
return strings.TrimSpace(t.Color) != "" || strings.TrimSpace(t.BackgroundColor) != ""
} Type guard
func hasVisual(theme *InlineStyleTheme) bool {
return theme != nil && (theme.Color != "" || theme.BackgroundColor != "")
} Try / catch
if _, _, err := model.SetInlineStyles(styles); err != nil {
if strings.Contains(err.Error(), "must define color or backgroundColor") {
// drop or complete the empty style, then retry
}
return err
} Prevention
- Require at least one color in the style editor before enabling Save
- Treat "clear color in both themes" as a delete action, not an update
- Check the trimmed values, since whitespace is stripped before validation
When it happens
Trigger: Calling model.SetInlineStyles / model.SetInlineStylesData with &InlineStyle{Light: &InlineStyleTheme{}, Dark: &InlineStyleTheme{...}} — both light fields empty; a style built from UI state where the user cleared both light inputs; JSON config with empty light color fields (e.g. after a bad merge); passing themes that only set non-support fields (Hidden, Name) and no color.
Common situations: A "reset/clear" action blanking the light theme while dark keeps values; form submission before the color picker commits; external tools exporting styles that legitimately have no light variant (not allowed here).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- inline style [ ] must define light and dark themes
- inline style name must not be empty
- inline style [ ] must use the same fields in light and dark…
- invalid dark theme of inline style
- all asset mappings failed
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/ec6f6466e6fecea9.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:693
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 {
return ret, nil
}
colorIndexes := make(map[int]struct{}, len(builtin.Colors))
for _, color := range builtin.Colors {View on GitHub (pinned to 9f775e8a12)