siyuan-note/siyuan · error
invalid dark theme of attribute view custom color [%d]: %w
Error message
invalid dark theme of attribute view custom color [%d]: %w
What it means
This error wraps a failure while normalizing the dark-theme half of a database (attribute view) custom color entry. Each custom color has light and dark themes, and each theme's foreground/background values are trimmed, lowercased, and regex-validated. The [%d] placeholder carries the color's Index so you can locate the offending entry in the palette config.
Source
Thrown at kernel/av/color.go:143
}
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)
}
return
}
// WorkspacePalette 返回当前工作空间的数据库自定义色和混排顺序。
func WorkspacePalette() (colors []*AttributeViewCustomColor, order []string) {View on GitHub (pinned to 8641553a1f)
Solutions
- Locate the custom color entry whose Index appears in the message and fix its dark theme color values to valid hex strings (e.g. #rrggbb)
- Validate colors with a regex such as ^#[0-9a-f]{6}$ (or the library's attributeViewColorPattern) before saving palette config
- Regenerate the palette from the UI instead of hand-editing configuration files
Example fix
// before
colors: [{index: 1, dark: {color: "red", backgroundColor: "#202020"}}]
// after
colors: [{index: 1, dark: {color: "#ff0000", backgroundColor: "#202020"}}] Defensive patterns
Strategy: validation
Validate before calling
const colorRe = /^#[0-9a-fA-F]{6}$/;
if (!colorRe.test(color.dark.color) || !colorRe.test(color.dark.backgroundColor)) throw new Error(`invalid dark color at index ${color.index}`); Type guard
function hasValidDarkTheme(c) { return c && c.dark && /^#[0-9a-f]{6}$/i.test(c.dark.color) && /^#[0-9a-f]{6}$/i.test(c.dark.backgroundColor); } Prevention
- Always store colors as full lowercase hex strings
- Validate palette JSON on import/sync before writing to config
- Regenerate colors via the UI rather than editing config by hand
When it happens
Trigger: Calling NormalizeAttributeViewCustomColors (or resolveColor via WorkspacePalette) with an AttributeViewCustomColor whose Dark.Color or Dark.BackgroundColor fails normalizeAttributeViewColorTheme's regex (attributeViewColorPattern).
Common situations: Hand-edited or synced conf files containing a dark color value that is not a valid hex color string (e.g. 'rgb(...)', empty string, '#GGGGGG', or with stray whitespace/case handled but format wrong).
Related errors
- attribute view not found
- invalid attribute view id
- view not found
- database [%s] template field [%s] rendering failed: %s
- invalid foreground color [%s]
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/f7e35a717403fd9b.
Report an issue: GitHub.