{"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":"exception","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/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L775-L811","documentation":"A theme pair for a builtin color or builtin style is missing one of its two halves: either `light` or `dark` is null. Builtin entries must always supply both themes so the editor can render consistently when the appearance theme mode switches. The description in the message identifies which entry (e.g. \"builtin color [3]\" or \"builtin style [warning]\").","triggerScenarios":"setInlineStylesData or loadInlineStyles with a builtin color/style entry that omits the `light` or `dark` key, or sets it to null, passed into normalizeInlineStyleThemePair via normalizeInlineStyleBuiltin.","commonSituations":"JSON hand-authored with only the current theme mode filled in; a serializer with `omitempty` dropping an empty theme object; partially completed edit of inline-styles.json.","solutions":["Add the missing `light` or `dark` theme object to the entry identified by the message prefix.","If both modes should look identical, still provide both objects with the same color/backgroundColor values.","Ensure the writing code does not use omitempty-style behavior on light/dark theme fields."],"exampleFix":"// before\n{\"index\": 2, \"light\": {\"backgroundColor\": \"#eeeeee\"}}\n// after\n{\"index\": 2, \"light\": {\"backgroundColor\": \"#eeeeee\"}, \"dark\": {\"backgroundColor\": \"#222222\"}}","handlingStrategy":"validation","validationCode":"for (const entry of entries) { // builtin colors and styles\n  if (!entry.light || !entry.dark) {\n    throw new Error(`${describe(entry)} must define light and dark themes`);\n  }\n}","typeGuard":"function hasThemePair(entry) {\n  return entry.light != null && entry.dark != null;\n}","tryCatchPattern":null,"preventionTips":["Always write both theme objects even when light and dark are identical.","Avoid omitempty-style serialization on light/dark theme fields."],"tags":["go","configuration","inline-styles","missing-field"],"backgroundTag":"missing-required-config-field","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}