{"record":{"id":"32bccc1cdc046c74","repo":"siyuan-note/siyuan","slug":"invalid-light-theme-of-attribute-view-custom-color","errorCode":null,"errorMessage":"invalid light theme of attribute view custom color [%d]: %w","messagePattern":"invalid light theme of attribute view custom color \\[(.+?)\\]: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/color.go","lineNumber":139,"sourceCode":"\tif nil == ret {\n\t\tret = []*AttributeViewCustomColor{}\n\t}\n\treturn\n}\n\nfunc normalizeAttributeViewCustomColor(color *AttributeViewCustomColor) (ret *AttributeViewCustomColor, err error) {\n\tif nil == color {\n\t\treturn nil, errors.New(\"attribute view custom color must not be null\")\n\t}\n\tif color.Index < CustomColorMinIndex || CustomColorMaxIndex < color.Index {\n\t\treturn nil, fmt.Errorf(\"attribute view custom color index [%d] is out of range [%d, %d]\",\n\t\t\tcolor.Index, CustomColorMinIndex, CustomColorMaxIndex)\n\t}\n\n\tret = &AttributeViewCustomColor{Index: color.Index, Hidden: color.Hidden}\n\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","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/color.go#L121-L157","documentation":"When normalizing a custom color, the Light theme variant is validated by normalizeAttributeViewColorTheme; if it fails (bad color format), the error is wrapped with this message identifying which color index has the invalid light theme. The %w wrap preserves the underlying cause such as \"invalid foreground color\".","triggerScenarios":"Calling NormalizeAttributeViewCustomColors with a color whose Light.Color or Light.BackgroundColor does not match attributeViewColorPattern (e.g. not a valid #rgb/#rrggbb form) after trimming/lowercasing.","commonSituations":"Users typing color names like \"red\" instead of hex; uppercase or whitespace is tolerated (normalized), but malformed hex like \"#12345\" or empty strings is not; palette JSON imported from third-party tools using rgb() notation.","solutions":["Set Light.Color and Light.BackgroundColor to valid hex values (matching attributeViewColorPattern, e.g. #rrggbb)","Check the wrapped inner error to see whether foreground or background color was invalid","Validate/convert color strings (rgb() to hex) before saving the palette"],"exampleFix":"// before\n&av.AttributeViewCustomColor{Index: 1, Light: av.AttributeViewColorTheme{Color: \"red\"}}\n// after\n&av.AttributeViewCustomColor{Index: 1, Light: av.AttributeViewColorTheme{Color: \"#ff0000\"}}","handlingStrategy":"validation","validationCode":"var colorRe = regexp.MustCompile(`^#[0-9a-f]{3}([0-9a-f]{3})?$`)\nif !colorRe.MatchString(strings.ToLower(strings.TrimSpace(c.Light.Color))) { return err }","typeGuard":null,"tryCatchPattern":"if _, err := av.NormalizeAttributeViewCustomColors(colors, true); err != nil {\n    if strings.Contains(err.Error(), \"invalid light theme\") { fixHex(colors, \"light\") }\n}","preventionTips":["Always store colors as lowercase hex #rgb or #rrggbb","Convert rgb()/named colors to hex before saving","Validate both light and dark themes with the same regex"],"tags":["attribute-view","color","validation"],"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"}