{"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/9f775e8a12daef8255556097396f9b2739078892/kernel/av/color.go#L125-L161","documentation":"Same validation as the light theme, but for the Dark theme variant of a custom color: if normalizeAttributeViewColorTheme fails on color.Dark, the cause is wrapped with this message identifying the color index. The wrapped cause names the specific offending field.","triggerScenarios":"Calling NormalizeAttributeViewCustomColors with a color whose Dark.Color or Dark.BackgroundColor fails the attributeViewColorPattern check after trim/lowercase normalization.","commonSituations":"Dark theme colors left empty or as placeholder text; palettes copied from tools that only export one theme and leave Dark with an invalid default; typos in hand-edited dark hex values.","solutions":["Set Dark.Color and Dark.BackgroundColor to valid hex values matching the pattern","If only one theme matters, copy the validated Light theme into Dark","Inspect the wrapped cause to see which field (foreground/background) failed"],"exampleFix":"// before\nDark: av.AttributeViewColorTheme{Color: \"\"}\n// after\nDark: av.AttributeViewColorTheme{Color: \"#111111\", BackgroundColor: \"#000000\"}","handlingStrategy":"validation","validationCode":"var colorRe = regexp.MustCompile(`^#[0-9a-f]{3}([0-9a-f]{3})?$`)\nif !colorRe.MatchString(strings.ToLower(strings.TrimSpace(c.Dark.Color))) { return err }","typeGuard":null,"tryCatchPattern":"if _, err := av.NormalizeAttributeViewCustomColors(colors, true); err != nil {\n    if strings.Contains(err.Error(), \"invalid dark theme\") { copyValidLightToDark(colors) }\n}","preventionTips":["Fill dark theme values whenever light theme is set","Default dark to the validated light value if no dark variant is intended","Validate with the same hex regex used for light"],"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"}