{"record":{"id":"f656bd99d14e125c","repo":"siyuan-note/siyuan","slug":"s-must-define-light-and-dark-themes","errorCode":null,"errorMessage":"%s must define light and dark themes","messagePattern":"(.+?) must define light and dark themes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":793,"sourceCode":"\nfunc normalizeInlineStyleAV(palette *InlineStyleAV, strict bool) (ret *InlineStyleAV, err error) {\n\tret = newEmptyInlineStyleAV()\n\tif palette == nil {\n\t\treturn ret, nil\n\t}\n\tcolors, err := av.NormalizeAttributeViewCustomColors(palette.Colors, strict)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tret.Colors = colors\n\tret.Order = av.NormalizeAttributeViewColorOrder(palette.Order, colors)\n\treturn ret, nil\n}\n\nfunc normalizeInlineStyleThemePair(light, dark *InlineStyleTheme, description string) (normalizedLight,\n\tnormalizedDark *InlineStyleTheme, err error) {\n\tif light == nil || dark == nil {\n\t\treturn nil, nil, fmt.Errorf(\"%s must define light and dark themes\", description)\n\t}\n\tif normalizedLight, err = normalizeInlineStyleTheme(light); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid light theme of %s: %w\", description, err)\n\t}\n\tif normalizedDark, err = normalizeInlineStyleTheme(dark); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid dark theme of %s: %w\", description, err)\n\t}\n\tlightColor, lightBackground := normalizedLight.Color != \"\", normalizedLight.BackgroundColor != \"\"\n\tdarkColor, darkBackground := normalizedDark.Color != \"\", normalizedDark.BackgroundColor != \"\"\n\tif !lightColor && !lightBackground {\n\t\treturn nil, nil, fmt.Errorf(\"%s must define color or backgroundColor\", description)\n\t}\n\tif lightColor != darkColor || lightBackground != darkBackground {\n\t\treturn nil, nil, fmt.Errorf(\"%s must use the same fields in light and dark themes\", description)\n\t}\n\treturn normalizedLight, normalizedDark, nil\n}\n","sourceCodeStart":775,"sourceCodeEnd":811,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L775-L811","documentation":"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]'.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\n{\"index\": 5, \"light\": {\"backgroundColor\": \"#fff3b8\"}, \"dark\": null}\n// after\n{\"index\": 5, \"light\": {\"backgroundColor\": \"#fff3b8\"}, \"dark\": {\"backgroundColor\": \"#4d3a00\"}}","handlingStrategy":"validation","validationCode":"for (const entry of [...(cfg.builtin?.colors ?? []), ...(cfg.builtin?.styles ?? [])]) {\n  const label = entry.index !== undefined ? `builtin color [${entry.index}]` : `builtin style [${entry.id}]`;\n  if (!entry.light || !entry.dark) throw new Error(`${label} must define light and dark themes`);\n}","typeGuard":"function hasBothThemes(e) { return e?.light != null && e?.dark != null; }","tryCatchPattern":"if _, err := setInlineStylesData(styles, currentAV); err != nil {\n    if strings.Contains(err.Error(), \"must define light and dark themes\") { /* fill in the missing theme from its counterpart */ }\n    return err\n}","preventionTips":["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"],"tags":["config","validation","missing-field","inline-styles"],"backgroundTag":"missing-required-config-field","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}