{"record":{"id":"06b6432220169fe8","repo":"glanceapp/glance","slug":"initializing-preset-theme-s-v","errorCode":null,"errorMessage":"initializing preset theme %s: %v","messagePattern":"initializing preset theme (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/glance.go","lineNumber":133,"sourceCode":"\t\tthemeProps = append(themeProps, &themeProperties{\n\t\t\tLight:                    true,\n\t\t\tBackgroundColor:          &hslColorField{240, 13, 95},\n\t\t\tPrimaryColor:             &hslColorField{230, 100, 30},\n\t\t\tNegativeColor:            &hslColorField{0, 70, 50},\n\t\t\tContrastMultiplier:       1.3,\n\t\t\tTextSaturationMultiplier: 0.5,\n\t\t})\n\n\t\tthemePresets, err := newOrderedYAMLMap(themeKeys, themeProps)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"creating theme presets: %v\", err)\n\t\t}\n\t\tconfig.Theme.Presets = *themePresets.Merge(&config.Theme.Presets)\n\n\t\tfor key, properties := range config.Theme.Presets.Items() {\n\t\t\tproperties.Key = key\n\t\t\tif err := properties.init(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"initializing preset theme %s: %v\", key, err)\n\t\t\t}\n\t\t}\n\t}\n\n\tconfig.Theme.Key = \"default\"\n\tif err := config.Theme.init(); err != nil {\n\t\treturn nil, fmt.Errorf(\"initializing default theme: %v\", err)\n\t}\n\n\t//\n\t// Init pages\n\t//\n\n\tapp.slugToPage[\"\"] = &config.Pages[0]\n\n\tproviders := &widgetProviders{\n\t\tassetResolver: app.StaticAssetPath,\n\t}","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/glance.go#L115-L151","documentation":"Startup fails when themeProperties.init() errors for a user-defined theme preset from config.Theme.Presets. init() compiles the theme style and preview templates and validates color fields, so the underlying cause (chained via %v) is typically a template execution failure or an invalid color value in the preset.","triggerScenarios":"Defining a custom preset under `theme.presets` with a malformed `color-scheme`, an invalid HSL/RGB/hex value in background-color/primary-color/negative-color, or fields that break the theme template (e.g. non-numeric multipliers).","commonSituations":"Typos in color hex strings, color-scheme values other than light/dark, setting contrast-multiplier/text-saturation-multiplier to strings or out-of-format values; presets written for an older glance version with renamed fields.","solutions":["Read the chained error: it identifies the failing field or template expression","Check every color field in the failing preset uses the documented format (e.g. `#1a1a1a`, hsl tuples, named values allowed by hslColorField decoding)","Simplify: comment out preset fields until it starts, then re-add the offending field corrected"],"exampleFix":"# before\ntheme:\n  presets:\n    my-theme:\n      color-scheme: lite\n# after\ntheme:\n  presets:\n    my-theme:\n      color-scheme: light\n","handlingStrategy":"validation","validationCode":"// Quick config sanity for preset fields (Go)\nvar probe struct{ Theme struct{ Presets map[string]struct{ ColorScheme string `yaml:\"color-scheme\"` } `yaml:\"presets\"` } `yaml:\"theme\"` }\nif err := yaml.Unmarshal(cfg, &probe); err != nil { return err }\nfor name, p := range probe.Theme.Presets {\n    if p.ColorScheme != \"\" && p.ColorScheme != \"light\" && p.ColorScheme != \"dark\" {\n        return fmt.Errorf(\"preset %s: color-scheme must be light or dark\", name)\n    }\n}\n","typeGuard":"func validColorScheme(s string) bool { return s == \"\" || s == \"light\" || s == \"dark\" }","tryCatchPattern":"Catch during startup, extract the preset name from the message plus the chained cause, and reject the config with both pieces of context.","preventionTips":["Copy preset examples from the current docs","Use documented color formats only","Test custom presets on a staging instance before the deployed one"],"tags":["themes","config","validation","startup"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}