glanceapp/glance · error
creating theme presets: %v
Error message
creating theme presets: %v
What it means
Startup fails when newOrderedYAMLMap cannot build the built-in theme preset map. Internally that constructor errors when the keys and values slices have different lengths; since both slices are hardcoded literals in glance.go (light/dark presets), a mismatch means the source was edited inconsistently or the function was reused with mismatched slices in a fork/plugin.
Source
Thrown at internal/glance/glance.go:126
defaultDarkTheme, ok := config.Theme.Presets.Get("default-dark")
if ok && !config.Theme.SameAs(defaultDarkTheme) || !config.Theme.SameAs(&themeProperties{}) {
themeKeys = append(themeKeys, "default-dark")
themeProps = append(themeProps, &themeProperties{})
}
themeKeys = append(themeKeys, "default-light")
themeProps = append(themeProps, &themeProperties{
Light: true,
BackgroundColor: &hslColorField{240, 13, 95},
PrimaryColor: &hslColorField{230, 100, 30},
NegativeColor: &hslColorField{0, 70, 50},
ContrastMultiplier: 1.3,
TextSaturationMultiplier: 0.5,
})
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 pagesView on GitHub (pinned to 91324e8de7)
Solutions
- If you edited the preset lists, make every key in themeKeys have exactly one entry in themeProps at the same index
- If using newOrderedYAMLMap in your own code, build both slices from a single source (one loop, or key/value pairs) so they cannot diverge
- Diff against upstream glance to find the accidental asymmetry
Example fix
// before (fork edit gone wrong)
themeKeys = append(themeKeys, "default-light")
// forgot: themeProps = append(themeProps, &themeProperties{...})
// after
themeKeys = append(themeKeys, "default-light")
themeProps = append(themeProps, &themeProperties{Light: true})
Defensive patterns
Strategy: validation
Validate before calling
// Guard the constructor invariant in your own code
if len(keys) != len(values) {
return nil, fmt.Errorf("keys/values length mismatch: %d vs %d", len(keys), len(values))
}
Try / catch
For fork/plugin code calling newOrderedYAMLMap, validate slice lengths first; in stock glance this error indicates a source edit — fix the edit, not a runtime catch.
Prevention
- Build key/value slices in one loop
- Add a unit test asserting len(themeKeys)==len(themeProps) when editing presets
- Keep preset key/property additions paired in the same commit
When it happens
Trigger: Calling newOrderedYAMLMap(themeKeys, themeProps) with len(themeKeys) != len(themeProps), or modifying the hardcoded preset lists in glance.go and adding a key without a matching properties entry.
Common situations: Fork maintainers adding a new built-in theme preset and forgetting the matching themeProperties entry; reusing newOrderedYAMLMap elsewhere with slices built by separate loops.
Related errors
- initializing preset theme %s: %v
- initializing default theme: %v
- invalid include match: %v
- decoding secret-key: %v
- secret-key must be exactly %d bytes
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/42e8a3d9eb4c98a9.
Report an issue: GitHub.