siyuan-note/siyuan · error
must define light and dark themes
Error message
%s must define light and dark themes
What it means
normalizeInlineStyleThemePair requires both a light theme and a dark theme pointer; a builtin color or style (and user style normalization reusing this helper) with only one theme — or with light/dark set to null in JSON — cannot render across theme switches and is rejected. The %s placeholder is a human-readable description such as 'builtin color [3]' or 'builtin style [error]'.
Solutions
- Add the missing theme object to the entry in inline-styles.json (define both light and dark)
- If only one appearance is intended, copy the existing theme to both light and dark
- Validate JSON structure (each entry needs light and dark objects) before saving
- Reload the workspace and toggle light/dark themes to confirm rendering
Example fix
// before
{"index": 5, "light": {"backgroundColor": "#fff3b8"}, "dark": null}
// after
{"index": 5, "light": {"backgroundColor": "#fff3b8"}, "dark": {"backgroundColor": "#4d3a00"}} Defensive patterns
Strategy: validation
Validate before calling
for (const entry of [...(cfg.builtin?.colors ?? []), ...(cfg.builtin?.styles ?? [])]) {
const label = entry.index !== undefined ? `builtin color [${entry.index}]` : `builtin style [${entry.id}]`;
if (!entry.light || !entry.dark) throw new Error(`${label} must define light and dark themes`);
} Type guard
function hasBothThemes(e) { return e?.light != null && e?.dark != null; } Try / catch
if _, err := setInlineStylesData(styles, currentAV); err != nil {
if strings.Contains(err.Error(), "must define light and dark themes") { /* fill in the missing theme from its counterpart */ }
return err
} Prevention
- Always author entries with both light and dark theme objects
- If a theme is undecided, duplicate the other theme as a placeholder
- Keep a template entry with light+dark shells to copy from
- Validate the structure (both keys present, non-null) before saving
When it happens
Trigger: setInlineStylesData or loadInlineStyles normalizes inline-styles.json where a builtin.colors or builtin.styles entry omits the light or dark object (`"dark": null` or missing key).
Common situations: Hand-editing the JSON and forgetting the dark theme; a generator written for light-mode-only config; copying an entry and deleting one theme object; assuming themes are optional.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- builtin color must not be null
- builtin style must not be null
- duplicate builtin color index
- duplicate builtin style ID
- invalid builtin style ID
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/f656bd99d14e125c.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/inline_style.go:793
func normalizeInlineStyleAV(palette *InlineStyleAV, strict bool) (ret *InlineStyleAV, err error) {
ret = newEmptyInlineStyleAV()
if palette == nil {
return ret, nil
}
colors, err := av.NormalizeAttributeViewCustomColors(palette.Colors, strict)
if err != nil {
return nil, err
}
ret.Colors = colors
ret.Order = av.NormalizeAttributeViewColorOrder(palette.Order, colors)
return ret, nil
}
func normalizeInlineStyleThemePair(light, dark *InlineStyleTheme, description string) (normalizedLight,
normalizedDark *InlineStyleTheme, err error) {
if light == nil || dark == nil {
return nil, nil, fmt.Errorf("%s must define light and dark themes", description)
}
if normalizedLight, err = normalizeInlineStyleTheme(light); err != nil {
return nil, nil, fmt.Errorf("invalid light theme of %s: %w", description, err)
}
if normalizedDark, err = normalizeInlineStyleTheme(dark); err != nil {
return nil, nil, fmt.Errorf("invalid dark theme of %s: %w", description, err)
}
lightColor, lightBackground := normalizedLight.Color != "", normalizedLight.BackgroundColor != ""
darkColor, darkBackground := normalizedDark.Color != "", normalizedDark.BackgroundColor != ""
if !lightColor && !lightBackground {
return nil, nil, fmt.Errorf("%s must define color or backgroundColor", description)
}
if lightColor != darkColor || lightBackground != darkBackground {
return nil, nil, fmt.Errorf("%s must use the same fields in light and dark themes", description)
}
return normalizedLight, normalizedDark, nil
}
View on GitHub (pinned to 9f775e8a12)