siyuan-note/siyuan · error
inline style [ ] must define light and dark themes
Error message
inline style [%s] must define light and dark themes
What it means
A custom inline style must always provide both a Light and a Dark InlineStyleTheme; a single-theme definition cannot render consistently when the user switches appearance modes. normalizeInlineStyles checks both pointers and rejects the whole save/load if either is nil.
Solutions
- Always populate both Light and Dark, using the same color for both if no dark variant is wanted
- Mirror the light theme into dark when a distinct dark palette is not needed: Dark: light
- Fix the config JSON so each style has both light and dark objects
- In builders, require both themes as parameters so the compiler prevents one-sided construction
Example fix
// before
&InlineStyle{ID: id, Name: n, Light: &InlineStyleTheme{Color: "#ff0000"}} // Dark nil
// after
&InlineStyle{ID: id, Name: n,
Light: &InlineStyleTheme{Color: "#ff0000"},
Dark: &InlineStyleTheme{Color: "#ff0000"}} Defensive patterns
Strategy: validation
Validate before calling
func hasBothThemes(s *InlineStyle) bool { return s.Light != nil && s.Dark != nil } Type guard
func completeStyle(s *InlineStyle) bool {
return s != nil && s.Light != nil && s.Dark != nil
} Try / catch
if _, _, err := model.SetInlineStyles(styles); err != nil {
if strings.Contains(err.Error(), "must define light and dark themes") {
// clone the present theme into the missing one and retry
}
return err
} Prevention
- Construct styles via a helper that takes both themes as required parameters
- Mirror the light theme into Dark when no distinct dark palette exists
- Never build InlineStyle literals that omit the Dark field
When it happens
Trigger: Calling model.SetInlineStyles / model.SetInlineStylesData with &InlineStyle{ID:..., Name:..., Light: l} and Dark left nil (or vice versa); JSON config where the dark object was deleted or the field name misspelled so it unmarshals to nil; code constructing themes conditionally and skipping the dark variant.
Common situations: Saving a style while the app is in light mode and code only fills the visible theme; hand-edited JSON dropping "dark"; an external migration tool copying only one theme; Go composite literals omitting the Dark field by mistake.
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 color or backgroundColor
- 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/5f759c43988b8d19.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:679
}
}
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 != ""
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)
}View on GitHub (pinned to 9f775e8a12)