{"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/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/color.go#L121-L157","documentation":"Wraps a failure from normalizeAttributeViewColorTheme for the LIGHT theme variant of a custom color. The theme color string failed validation (wrong format or value), and the wrapper records which color index and which theme (light) was at fault using %w so the cause stays unwrappable.","triggerScenarios":"normalizeAttributeViewCustomColor at color.go:139 when color.Light fails theme normalization; stored custom color Light values that are not valid theme color strings (e.g. missing var(--b3-...) format, unsupported hex, empty string where a color is required).","commonSituations":"Hand-edited .av JSON with a malformed light-theme color; a palette importer writing hex colors where the kernel expects CSS variables or a specific format; truncation/corruption of the color string during sync.","solutions":["Unwrap the %w cause in the message to see the exact theme-color rule violated, then correct color.Light to the expected format.","Use valid CSS color values accepted by normalizeAttributeViewColorTheme (e.g. var(--b3-*) variables or supported color formats).","Re-copy the color from a working configuration or regenerate it via the attribute view UI instead of hand-editing.","Validate both Light and Dark values with the same normalizer before persisting custom colors."],"exampleFix":"// before\nLight: \"#abc\" // or malformed string rejected by the theme normalizer\n\n// after\nLight: \"var(--b3-font-color6)\" // valid theme color reference","handlingStrategy":"validation","validationCode":"func themeColorValid(s string) bool {\n\t// must satisfy normalizeAttributeViewColorTheme, e.g. var(--b3-...) or accepted hex\n\treturn s != \"\" && (strings.HasPrefix(s, \"var(--b3-\") || isSupportedHex(s))\n}","typeGuard":null,"tryCatchPattern":"if _, err := av.NormalizeAttributeViewCustomColors(colors, true); err != nil && strings.Contains(err.Error(), \"invalid light theme\") {\n\tvar wrapped error\n\terrors.As(err, &wrapped) // unwrap %w cause for the exact rule violated\n}","preventionTips":["Use theme color references (var(--b3-*)) or kernel-supported formats for Light/Dark","Validate both Light and Dark values with normalizeAttributeViewColorTheme before persisting","Avoid hand-editing color strings in .av JSON; use the UI or NextCustomColorIndex-based code"],"tags":["attribute-view","custom-color","color-theme","validation","siyuan-kernel"],"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"}