{"record":{"id":"c0c47bb3996a7a1f","repo":"siyuan-note/siyuan","slug":"invalid-light-theme-of-inline-style-s-w","errorCode":null,"errorMessage":"invalid light theme of inline style [%s]: %w","messagePattern":"invalid light theme of inline style \\[(.+?)\\]: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":684,"sourceCode":"\t\tif _, exists := ids[id]; exists {\n\t\t\treturn nil, fmt.Errorf(\"duplicate inline style ID [%s]\", id)\n\t\t}\n\t\tids[id] = struct{}{}\n\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}","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L666-L702","documentation":"The light theme of an inline style is validated by normalizeInlineStyleTheme, which requires Color and BackgroundColor to be empty or match the #RRGGBB pattern (case-insensitive; the value is lowercased). Any malformed color string in style.Light causes this wrapped error identifying the style by ID.","triggerScenarios":"setInlineStylesData or loadInlineStyles processes an InlineStyle whose Light.Color or Light.BackgroundColor is not a valid #RRGGBB hex value — e.g. \"red\", \"#fff\", \"ff0000\", \"#GGHHII\", or rgb(...) strings.","commonSituations":"Users pasting CSS color names or shorthand hex into a custom style config; scripts interpolating colors without formatting; importing styles from other apps that use 3-digit hex or rgb().","solutions":["Convert the color to 6-digit lowercase-able hex form #RRGGBB (expand #FFF to #FFFFFF, resolve color names to hex).","Validate all colors client-side against ^#[0-9a-fA-F]{6}$ before submitting the style list.","Fix the on-disk inline-styles JSON, replacing the offending Light color value."],"exampleFix":"// before\nLight: &InlineStyleTheme{Color: \"red\"}\n// after\nLight: &InlineStyleTheme{Color: \"#ff0000\"}","handlingStrategy":"validation","validationCode":"const hex6 = /^#[0-9a-fA-F]{6}$/; if (theme.Color && !hex6.test(theme.Color)) throw new Error(`bad light color ${theme.Color}`); if (theme.BackgroundColor && !hex6.test(theme.BackgroundColor)) throw new Error('bad light backgroundColor');","typeGuard":"const isValidColor = (c: string): boolean => c === '' || /^#[0-9a-fA-F]{6}$/.test(c);","tryCatchPattern":"try { await saveStyles(styles) } catch (e) { if (/invalid light theme/.test(String(e))) { /* surface the style ID and offending color to the user, fix, retry */ } }","preventionTips":["Use a hex color picker (6-digit output) in any UI writing these values","Convert 3-digit hex and color names to #RRGGBB before submitting","Remember only Color/BackgroundColor are allowed — no alpha (use the separate fields if available)"],"tags":["validation","color-format","inline-styles","hex"],"backgroundTag":"invalid-argument-format","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}