{"record":{"id":"9a5ee4213ad65c79","repo":"siyuan-note/siyuan","slug":"invalid-backgroundcolor-w","errorCode":null,"errorMessage":"invalid backgroundColor: %w","messagePattern":"invalid backgroundColor: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":859,"sourceCode":"\t\tif _, exists := seen[id]; exists {\n\t\t\tcontinue\n\t\t}\n\t\tseen[id] = struct{}{}\n\t\tret = append(ret, id)\n\t}\n\tsort.Slice(ret, func(i, j int) bool {\n\t\treturn builtinStyleOrder[ret[i]] < builtinStyleOrder[ret[j]]\n\t})\n\treturn ret, nil\n}\n\nfunc normalizeInlineStyleTheme(theme *InlineStyleTheme) (ret *InlineStyleTheme, err error) {\n\tret = &InlineStyleTheme{}\n\tif ret.Color, err = normalizeInlineStyleColor(theme.Color); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid color: %w\", err)\n\t}\n\tif ret.BackgroundColor, err = normalizeInlineStyleColor(theme.BackgroundColor); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid backgroundColor: %w\", err)\n\t}\n\treturn ret, nil\n}\n\nfunc normalizeInlineStyleColor(color string) (ret string, err error) {\n\tret = strings.ToLower(strings.TrimSpace(color))\n\tif ret == \"\" {\n\t\treturn ret, nil\n\t}\n\tif !inlineStyleColorPattern.MatchString(ret) {\n\t\treturn \"\", fmt.Errorf(\"color [%s] must use #RRGGBB format\", color)\n\t}\n\treturn ret, nil\n}\n\nfunc init() {\n\tav.LoadWorkspacePalette = loadWorkspaceAVPalette\n}","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/inline_style.go#L841-L877","documentation":"Same validation path as the color error, but for the BackgroundColor field of an inline style theme: normalizeInlineStyleTheme wraps the normalizeInlineStyleColor failure for BackgroundColor with \"invalid backgroundColor\". The value was non-empty yet not a valid normalized color string.","triggerScenarios":"Saving an inline style theme whose backgroundColor is a malformed value like \"lightblue\", \"#12345\", \"rgb(0,0,0)\", or contains stray whitespace/uppercase-plus-wrong-length hex.","commonSituations":"Pasting background colors from CSS or design tools in formats other than #RRGGBB; config migrations that stored old color formats; typos in hex digits.","solutions":["Rewrite the background color as 6-digit hex #RRGGBB (lowercase is applied automatically)","Clear backgroundColor (empty string) if no background is intended — empty is valid","Validate the hex pattern before saving from plugins/scripts"],"exampleFix":"// before\nbackgroundColor: \"rgb(255, 0, 0)\"\n// after\nbackgroundColor: \"#ff0000\"","handlingStrategy":"validation","validationCode":"const HEX6 = /^#[0-9a-fA-F]{6}$/;\nfunction validBackgroundColor(c) { return c === \"\" || HEX6.test(c.trim()); }","typeGuard":"const isHexColor = v => typeof v === \"string\" && /^#[0-9a-fA-F]{6}$/.test(v.trim());","tryCatchPattern":"try { saveTheme(t); } catch (e) { if (String(e).includes(\"invalid backgroundColor\")) { t.backgroundColor = \"\"; saveTheme(t); } }","preventionTips":["Validate backgroundColor with the same #RRGGBB rule as color","Convert rgb()/rgba() inputs to hex before submitting","Keep a single shared color-normalization helper for both fields"],"tags":["validation","color","inline-style","format"],"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"}