{"record":{"id":"c211e88797b57dd7","repo":"glanceapp/glance","slug":"initializing-default-theme-v","errorCode":null,"errorMessage":"initializing default theme: %v","messagePattern":"initializing default theme: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/glance.go","lineNumber":140,"sourceCode":"\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}\n\n\tfor p := range config.Pages {\n\t\tpage := &config.Pages[p]\n\t\tpage.PrimaryColumnIndex = -1\n\n\t\tif page.Slug == \"\" {\n\t\t\tpage.Slug = titleToSlug(page.Title)","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/glance.go#L122-L158","documentation":"Startup fails when the top-level `theme` configuration's init() errors. After presets are merged, glance sets Theme.Key to \"default\" and initializes the active theme — compiling its CSS/preview templates and resolving its colors. The chained %v error comes from that same init() path: bad color values, an invalid `default` preset reference, or a template failure.","triggerScenarios":"Setting top-level theme fields (color-scheme, background-color, primary-color, negative-color, contrast-multiplier, text-saturation-multiplier) to invalid values, or referencing `presets` data that breaks the merged theme's template rendering.","commonSituations":"A global theme typo like `color-scheme: darkk`; a hex color missing the '#'; copy-pasting theme blocks from a glance version whose template expects different fields; invalid float values for multipliers.","solutions":["Read the chained error for the specific failing field or template","Validate each top-level theme field against the docs: color-scheme in {light, dark}, colors in supported formats, multipliers numeric","Temporarily remove custom theme overrides to confirm the default theme starts, then re-add fields one by one"],"exampleFix":"# before\ntheme:\n  background-color: 151519   # missing '#'\n# after\ntheme:\n  background-color: \"#151519\"\n","handlingStrategy":"validation","validationCode":"// Validate top-level theme fields before startup\nvar t struct{ ColorScheme string `yaml:\"color-scheme\"`; BackgroundColor string `yaml:\"background-color\"` }\nyaml.Unmarshal(cfg, &struct{ Theme typeof(t) `yaml:\"theme\"` }{}) // or inline struct\nif t.ColorScheme != \"\" && t.ColorScheme != \"light\" && t.ColorScheme != \"dark\" { return errors.New(\"theme.color-scheme invalid\") }\n","typeGuard":"func validHex(s string) bool { if s == \"\" { return true }; _, err := colorful.Hex(s); return err == nil }","tryCatchPattern":"Fail fast with the chained init() cause; surface which theme field is implicated rather than retrying startup.","preventionTips":["Quote hex colors and include the leading '#','Keep multipliers as bare numeric scalars","Diff theme blocks against docs after version upgrades"],"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"}