{"record":{"id":"9a5ee4213ad65c79","repo":"siyuan-note/siyuan","slug":"invalid-backgroundcolor-w","errorCode":null,"errorMessage":"invalid backgroundColor: %w","messagePattern":"invalid backgroundColor: %w","errorType":"exception","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/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L841-L877","documentation":"Identical to the color case but for the BackgroundColor field: normalizeInlineStyleTheme validates BackgroundColor via normalizeInlineStyleColor and wraps any failure as \"invalid backgroundColor: %w\". A theme half may leave BackgroundColor empty (\"\"), but a non-empty value must be a valid color.","triggerScenarios":"Saving an inline style theme whose light or dark half has a BackgroundColor that fails normalizeInlineStyleColor in kernel/model/inline_style.go — non-hex strings, 3-digit shorthand, or malformed values.","commonSituations":"Programmatic theme builders assigning CSS background values like \"transparent\" or \"rgba(...)\"; copied style strings containing trailing characters; hand-edited config JSON with malformed hex.","solutions":["Set BackgroundColor to \"\" if no background is desired, or to a valid lowercase #RRGGBB string.","Convert rgba()/named colors to 6-digit hex before saving.","Inspect the wrapped error to identify the exact invalid value."],"exampleFix":"// before\ntheme.BackgroundColor = \"rgba(0,0,0,0.5)\" // rejected\n// after\ntheme.BackgroundColor = \"#000000\" // or \"\" for none","handlingStrategy":"validation","validationCode":"function isValidThemeBackgroundColor(c) {\n  return c === \"\" || /^#[0-9a-fA-F]{6}$/.test(c);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use \"\" (empty string) to mean 'no background' — never \"transparent\" or rgba().","Convert alpha backgrounds to solid #RRGGBB equivalents before saving.","Validate both theme halves with the same helper to keep behavior symmetric."],"tags":["validation","color-format","inline-style"],"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-14T05:17:10.506Z"}