{"record":{"id":"ad23240e7c535ce3","repo":"siyuan-note/siyuan","slug":"invalid-background-color-s","errorCode":null,"errorMessage":"invalid background color [%s]","messagePattern":"invalid background color \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/color.go","lineNumber":155,"sourceCode":"\tret.Light, err = normalizeAttributeViewColorTheme(color.Light)\n\tif nil != err {\n\t\treturn nil, fmt.Errorf(\"invalid light theme of attribute view custom color [%d]: %w\", color.Index, err)\n\t}\n\tret.Dark, err = normalizeAttributeViewColorTheme(color.Dark)\n\tif nil != err {\n\t\treturn nil, fmt.Errorf(\"invalid dark theme of attribute view custom color [%d]: %w\", color.Index, err)\n\t}\n\treturn\n}\n\nfunc normalizeAttributeViewColorTheme(theme AttributeViewColorTheme) (ret AttributeViewColorTheme, err error) {\n\tret.Color = strings.ToLower(strings.TrimSpace(theme.Color))\n\tret.BackgroundColor = strings.ToLower(strings.TrimSpace(theme.BackgroundColor))\n\tif !attributeViewColorPattern.MatchString(ret.Color) {\n\t\treturn AttributeViewColorTheme{}, fmt.Errorf(\"invalid foreground color [%s]\", theme.Color)\n\t}\n\tif !attributeViewColorPattern.MatchString(ret.BackgroundColor) {\n\t\treturn AttributeViewColorTheme{}, fmt.Errorf(\"invalid background color [%s]\", theme.BackgroundColor)\n\t}\n\treturn\n}\n\n// WorkspacePalette 返回当前工作空间的数据库自定义色和混排顺序。\nfunc WorkspacePalette() (colors []*AttributeViewCustomColor, order []string) {\n\tif LoadWorkspacePalette != nil {\n\t\tcolors, order = LoadWorkspacePalette()\n\t}\n\tif nil == colors {\n\t\tcolors = []*AttributeViewCustomColor{}\n\t}\n\torder = NormalizeAttributeViewColorOrder(order, colors)\n\treturn\n}\n\n// DefaultAttributeViewColorOrder 返回内置色在前、自定义色按编号排列的默认顺序。\nfunc DefaultAttributeViewColorOrder(colors []*AttributeViewCustomColor) []string {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/color.go#L137-L173","documentation":"Identical validation to the foreground color, applied to the theme's BackgroundColor: it must match attributeViewColorPattern after lowercasing and trimming, otherwise the theme is rejected with this error quoting the original input.","triggerScenarios":"Calling normalizeAttributeViewCustomColor with theme.BackgroundColor set to a non-hex value (empty string, CSS name, rgb() notation, malformed hex).","commonSituations":"Background color left as \"transparent\" or \"none\" (not accepted); only the foreground was updated and the background kept an old placeholder; third-party theme exports using non-hex notation.","solutions":["Convert the background color to valid #rgb/#rrggbb hex","Remove the placeholder value and pick a concrete hex color","Validate both Color and BackgroundColor with the same regex before persisting"],"exampleFix":"// before\nTheme{Color: \"#ffffff\", BackgroundColor: \"transparent\"}\n// after\nTheme{Color: \"#ffffff\", BackgroundColor: \"#000000\"}","handlingStrategy":"validation","validationCode":"var colorRe = regexp.MustCompile(`^#[0-9a-f]{3}([0-9a-f]{3})?$`)\nif !colorRe.MatchString(strings.ToLower(strings.TrimSpace(theme.BackgroundColor))) { return err }","typeGuard":null,"tryCatchPattern":"if _, err := av.NormalizeAttributeViewCustomColors(colors, true); err != nil {\n    if strings.Contains(err.Error(), \"invalid background color\") { setFallbackBackground(colors) }\n}","preventionTips":["Do not use \"transparent\" or \"none\"; pick a concrete hex value","Validate background together with foreground before persisting","Provide a default hex background in UI inputs"],"tags":["attribute-view","color","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"}