siyuan-note/siyuan · error
inline style [ ] must use the same fields in light and dark…
Error message
inline style [%s] must use the same fields in light and dark themes
What it means
Light and dark themes must use the SAME property set: either both define Color, or both define BackgroundColor (or both define both). Mixed usage — e.g. light uses Color while dark uses only BackgroundColor — would make the styled span's appearance property change with the theme, so normalizeInlineStyles rejects the whole save/load.
Solutions
- Set the same field(s) on both themes: give dark its own Color if light uses Color
- To visually adapt for dark mode, change the VALUE (e.g. light Color #111 -> dark Color #eee), not the field
- Keep both Color and BackgroundColor on both themes if the style uses both
- Validate parity client-side: hasColor(light)==hasColor(dark) && hasBg(light)==hasBg(dark) before calling the API
Example fix
// before
Light: &InlineStyleTheme{Color: "#c00"},
Dark: &InlineStyleTheme{BackgroundColor: "#3a2b2b"} // different field
// -> inline style [id] must use the same fields in light and dark themes
// after
Light: &InlineStyleTheme{Color: "#c00"},
Dark: &InlineStyleTheme{Color: "#ff8a8a"} // same field, dark-appropriate value Defensive patterns
Strategy: validation
Validate before calling
func themesUseSameFields(l, d *InlineStyleTheme) bool {
lc, lb := l.Color != "", l.BackgroundColor != ""
dc, db := d.Color != "", d.BackgroundColor != ""
return lc == dc && lb == db
} Try / catch
if _, _, err := model.SetInlineStylesData(cfg); err != nil {
if strings.Contains(err.Error(), "must use the same fields") {
// mirror field usage across themes and retry
}
return err
} Prevention
- Always build light and dark themes from one template so field usage stays in sync
- Adapt dark mode by changing color VALUES, never by switching Color<->BackgroundColor
- Validate field parity client-side before each save
When it happens
Trigger: Calling model.SetInlineStyles / model.SetInlineStylesData with Light{Color: X} and Dark{BackgroundColor: Y}; clearing one property in one theme while keeping it in the other; JSON config where one theme's field was deleted or renamed; copying a color into the wrong field (Color vs BackgroundColor) for one theme.
Common situations: Designing a dark mode variant as "background highlight instead of text color" (a common style instinct, but not allowed per style); a merge that dropped a field from one theme; a UI bug resetting one picker but not the other.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- inline style [ ] must define color or backgroundColor
- inline style [ ] must define light and dark themes
- invalid dark theme of inline style
- all asset mappings failed
- assetPath is not an image referenced by the document
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/4208e3bb72316f8a.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:696
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 {
if color == nil {
return nil, errors.New("builtin color must not be null")
}View on GitHub (pinned to 9f775e8a12)