siyuan-note/siyuan · error
invalid light theme of attribute view custom color
Error message
invalid light theme of attribute view custom color [%d]: %w
What it means
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".
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
Example fix
// before
&av.AttributeViewCustomColor{Index: 1, Light: av.AttributeViewColorTheme{Color: "red"}}
// after
&av.AttributeViewCustomColor{Index: 1, Light: av.AttributeViewColorTheme{Color: "#ff0000"}} Defensive patterns
Strategy: validation
Validate before calling
var colorRe = regexp.MustCompile(`^#[0-9a-f]{3}([0-9a-f]{3})?$`)
if !colorRe.MatchString(strings.ToLower(strings.TrimSpace(c.Light.Color))) { return err } Try / catch
if _, err := av.NormalizeAttributeViewCustomColors(colors, true); err != nil {
if strings.Contains(err.Error(), "invalid light theme") { fixHex(colors, "light") }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- invalid dark theme of attribute view custom color
- at least one visible view is required
- attribute view custom color index
- attribute view custom color must not be null
- attribute view custom colors count exceeds the
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/32bccc1cdc046c74.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/color.go:139
if nil == ret {
ret = []*AttributeViewCustomColor{}
}
return
}
func normalizeAttributeViewCustomColor(color *AttributeViewCustomColor) (ret *AttributeViewCustomColor, err error) {
if nil == color {
return nil, errors.New("attribute view custom color must not be null")
}
if color.Index < CustomColorMinIndex || CustomColorMaxIndex < color.Index {
return nil, fmt.Errorf("attribute view custom color index [%d] is out of range [%d, %d]",
color.Index, CustomColorMinIndex, CustomColorMaxIndex)
}
ret = &AttributeViewCustomColor{Index: color.Index, Hidden: color.Hidden}
ret.Light, err = normalizeAttributeViewColorTheme(color.Light)
if nil != err {
return nil, fmt.Errorf("invalid light theme of attribute view custom color [%d]: %w", color.Index, err)
}
ret.Dark, err = normalizeAttributeViewColorTheme(color.Dark)
if nil != err {
return nil, fmt.Errorf("invalid dark theme of attribute view custom color [%d]: %w", color.Index, err)
}
return
}
func normalizeAttributeViewColorTheme(theme AttributeViewColorTheme) (ret AttributeViewColorTheme, err error) {
ret.Color = strings.ToLower(strings.TrimSpace(theme.Color))
ret.BackgroundColor = strings.ToLower(strings.TrimSpace(theme.BackgroundColor))
if !attributeViewColorPattern.MatchString(ret.Color) {
return AttributeViewColorTheme{}, fmt.Errorf("invalid foreground color [%s]", theme.Color)
}
if !attributeViewColorPattern.MatchString(ret.BackgroundColor) {
return AttributeViewColorTheme{}, fmt.Errorf("invalid background color [%s]", theme.BackgroundColor)
}
returnView on GitHub (pinned to 9f775e8a12)