glanceapp/glance · error
initializing default theme: %v
Error message
initializing default theme: %v
What it means
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.
Source
Thrown at internal/glance/glance.go:140
})
themePresets, err := newOrderedYAMLMap(themeKeys, themeProps)
if err != nil {
return nil, fmt.Errorf("creating theme presets: %v", err)
}
config.Theme.Presets = *themePresets.Merge(&config.Theme.Presets)
for key, properties := range config.Theme.Presets.Items() {
properties.Key = key
if err := properties.init(); err != nil {
return nil, fmt.Errorf("initializing preset theme %s: %v", key, err)
}
}
}
config.Theme.Key = "default"
if err := config.Theme.init(); err != nil {
return nil, fmt.Errorf("initializing default theme: %v", err)
}
//
// Init pages
//
app.slugToPage[""] = &config.Pages[0]
providers := &widgetProviders{
assetResolver: app.StaticAssetPath,
}
for p := range config.Pages {
page := &config.Pages[p]
page.PrimaryColumnIndex = -1
if page.Slug == "" {
page.Slug = titleToSlug(page.Title)View on GitHub (pinned to 91324e8de7)
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
Example fix
# before theme: background-color: 151519 # missing '#' # after theme: background-color: "#151519"
Defensive patterns
Strategy: validation
Validate before calling
// Validate top-level theme fields before startup
var t struct{ ColorScheme string `yaml:"color-scheme"`; BackgroundColor string `yaml:"background-color"` }
yaml.Unmarshal(cfg, &struct{ Theme typeof(t) `yaml:"theme"` }{}) // or inline struct
if t.ColorScheme != "" && t.ColorScheme != "light" && t.ColorScheme != "dark" { return errors.New("theme.color-scheme invalid") }
Type guard
func validHex(s string) bool { if s == "" { return true }; _, err := colorful.Hex(s); return err == nil } Try / catch
Fail fast with the chained init() cause; surface which theme field is implicated rather than retrying startup.
Prevention
- Quote hex colors and include the leading '#','Keep multipliers as bare numeric scalars
- Diff theme blocks against docs after version upgrades
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- initializing preset theme %s: %v
- secret-key must be exactly %d bytes
- validating config file: %w
- URL is required
- nested groups are not supported
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/c211e88797b57dd7.
Report an issue: GitHub.