{"record":{"id":"0c4f45e155fd10ed","repo":"siyuan-note/siyuan","slug":"invalid-dark-theme-of-inline-style-s-w","errorCode":null,"errorMessage":"invalid dark theme of inline style [%s]: %w","messagePattern":"invalid dark theme of inline style \\[(.+?)\\]: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":688,"sourceCode":"\n\t\tname := strings.TrimSpace(style.Name)\n\t\tif name == \"\" {\n\t\t\treturn nil, errors.New(\"inline style name must not be empty\")\n\t\t}\n\t\tif maxInlineStyleNameRunes < utf8.RuneCountInString(name) {\n\t\t\treturn nil, fmt.Errorf(\"inline style name exceeds the %d character limit\", maxInlineStyleNameRunes)\n\t\t}\n\t\tif style.Light == nil || style.Dark == nil {\n\t\t\treturn nil, fmt.Errorf(\"inline style [%s] must define light and dark themes\", id)\n\t\t}\n\n\t\tlight, err := normalizeInlineStyleTheme(style.Light)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid light theme of inline style [%s]: %w\", id, err)\n\t\t}\n\t\tdark, err := normalizeInlineStyleTheme(style.Dark)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid dark theme of inline style [%s]: %w\", id, err)\n\t\t}\n\t\tlightColor, lightBackground := light.Color != \"\", light.BackgroundColor != \"\"\n\t\tdarkColor, darkBackground := dark.Color != \"\", dark.BackgroundColor != \"\"\n\t\tif !lightColor && !lightBackground {\n\t\t\treturn nil, fmt.Errorf(\"inline style [%s] must define color or backgroundColor\", id)\n\t\t}\n\t\tif lightColor != darkColor || lightBackground != darkBackground {\n\t\t\treturn nil, fmt.Errorf(\"inline style [%s] must use the same fields in light and dark themes\", id)\n\t\t}\n\n\t\tret = append(ret, &InlineStyle{ID: id, Name: name, Hidden: style.Hidden, Light: light, Dark: dark})\n\t}\n\treturn ret, nil\n}\n\nfunc normalizeInlineStyleBuiltin(builtin *InlineStyleBuiltin) (ret *InlineStyleBuiltin, err error) {\n\tret = newEmptyInlineStyleBuiltin()\n\tif builtin == nil {","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L670-L706","documentation":"Identical to error 1586 but for the Dark theme: normalizeInlineStyleTheme validates Dark.Color and Dark.BackgroundColor against the #RRGGBB pattern, and any malformed value aborts the whole save/load with this wrapped message naming the style ID.","triggerScenarios":"Calling model.SetInlineStyles / model.SetInlineStylesData with Dark.Color or Dark.BackgroundColor set to a non-#RRGGBB value (named color, rgba(), 3-digit hex, missing #, 8-digit hex); loading a config whose dark-theme colors were written by an external tool in CSS syntax.","commonSituations":"Designers hand-picking a darker variant in CSS notation (e.g. \"rgba(0,0,0,.5)\") for the dark theme; scripts converting theme palettes that emit different formats for dark colors; stale entries from an older config version.","solutions":["Rewrite the dark theme color as strict #RRGGBB lowercase hex","Apply the same conversion routine to both themes so neither drifts out of format","Leave the field as \"\" if the dark theme should omit that property (but see error 1589: field usage must match light)","Validate both colors with ^#[0-9a-f]{6}$ before calling the API"],"exampleFix":"// before\nDark: &InlineStyleTheme{BackgroundColor: \"rgba(0,0,0,0.2)\"}\n// -> invalid dark theme of inline style [id]: invalid backgroundColor: ...\n// after\nDark: &InlineStyleTheme{BackgroundColor: \"#000000\"} // opacity via the style's other means, not alpha","handlingStrategy":"validation","validationCode":"var colorRe = regexp.MustCompile(`^#[0-9a-f]{6}$`)\nfunc validDarkTheme(t *InlineStyleTheme) bool {\n\tc := strings.ToLower(strings.TrimSpace(t.Color))\n\tb := strings.ToLower(strings.TrimSpace(t.BackgroundColor))\n\treturn (c == \"\" || colorRe.MatchString(c)) && (b == \"\" || colorRe.MatchString(b))\n}","typeGuard":"func isHexColor(s string) bool {\n\tm, _ := regexp.MatchString(`^#[0-9a-fA-F]{6}$`, strings.TrimSpace(s))\n\treturn m\n}","tryCatchPattern":"if _, _, err := model.SetInlineStylesData(cfg); err != nil {\n\tif strings.Contains(err.Error(), \"invalid dark theme\") {\n\t\t// fix Dark.Color / Dark.BackgroundColor to #RRGGBB and retry\n\t}\n\treturn err\n}","preventionTips":["Apply the same color converter to dark values — do not special-case dark colors","Reject rgba()/alpha values at input time since #RRGGBB has no alpha channel","Round-trip-test theme exports through the validator before writing config"],"tags":["go","validation","color-format","themes"],"backgroundTag":"invalid-argument-format","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"}