{"record":{"id":"f7e35a717403fd9b","repo":"siyuan-note/siyuan","slug":"invalid-dark-theme-of-attribute-view-custom-color","errorCode":null,"errorMessage":"invalid dark theme of attribute view custom color [%d]: %w","messagePattern":"invalid dark theme of attribute view custom color \\[(.+?)\\]: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/color.go","lineNumber":143,"sourceCode":"}\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\n}\n\n// WorkspacePalette 返回当前工作空间的数据库自定义色和混排顺序。\nfunc WorkspacePalette() (colors []*AttributeViewCustomColor, order []string) {","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/color.go#L125-L161","documentation":"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.","triggerScenarios":"Calling NormalizeAttributeViewCustomColors (or resolveColor via WorkspacePalette) with an AttributeViewCustomColor whose Dark.Color or Dark.BackgroundColor fails normalizeAttributeViewColorTheme's regex (attributeViewColorPattern).","commonSituations":"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).","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"],"exampleFix":"// before\ncolors: [{index: 1, dark: {color: \"red\", backgroundColor: \"#202020\"}}]\n// after\ncolors: [{index: 1, dark: {color: \"#ff0000\", backgroundColor: \"#202020\"}}]","handlingStrategy":"validation","validationCode":"const colorRe = /^#[0-9a-fA-F]{6}$/;\nif (!colorRe.test(color.dark.color) || !colorRe.test(color.dark.backgroundColor)) throw new Error(`invalid dark color at index ${color.index}`);","typeGuard":"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); }","tryCatchPattern":null,"preventionTips":["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"],"tags":["database","attribute-view","color-validation"],"backgroundTag":"invalid-color-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"}