glanceapp/glance · error
compiling theme preview: %v
Error message
compiling theme preview: %v
What it means
Returned by themeProperties.init() when executing themePresetPreviewTemplate fails — the small HTML preview rendered for each preset on the themes page. Same root causes as the style template: theme property values that decode but cannot be rendered, or (in forks) template expressions referencing missing fields.
Source
Thrown at internal/glance/theme.go:65
ContrastMultiplier float32 `yaml:"contrast-multiplier"`
TextSaturationMultiplier float32 `yaml:"text-saturation-multiplier"`
Key string `yaml:"-"`
CSS template.CSS `yaml:"-"`
PreviewHTML template.HTML `yaml:"-"`
BackgroundColorAsHex string `yaml:"-"`
}
func (t *themeProperties) init() error {
css, err := executeTemplateToString(themeStyleTemplate, t)
if err != nil {
return fmt.Errorf("compiling theme style: %v", err)
}
t.CSS = template.CSS(whitespaceAtBeginningOfLinePattern.ReplaceAllString(css, ""))
previewHTML, err := executeTemplateToString(themePresetPreviewTemplate, t)
if err != nil {
return fmt.Errorf("compiling theme preview: %v", err)
}
t.PreviewHTML = template.HTML(previewHTML)
if t.BackgroundColor != nil {
t.BackgroundColorAsHex = t.BackgroundColor.ToHex()
} else {
t.BackgroundColorAsHex = "#151519"
}
return nil
}
func (t1 *themeProperties) SameAs(t2 *themeProperties) bool {
if t1 == nil && t2 == nil {
return true
}
if t1 == nil || t2 == nil {
return falseView on GitHub (pinned to 91324e8de7)
Solutions
- Read the chained error to find the failing preset/field
- Make each preset fully specify documented fields with valid formats
- Test presets one at a time to identify the offender
Defensive patterns
Strategy: validation
Validate before calling
// Ensure every preset supplies required renderable fields (e.g. colors present or omitted consistently)
for _, p := range presets {
if p.ColorScheme != "" && !validColorScheme(p.ColorScheme) { return fmt.Errorf("invalid color-scheme in preset") }
if !validMultiplier(p.ContrastMultiplier) { return fmt.Errorf("invalid multiplier in preset") }
}
Try / catch
Catch at preset init (message includes the preset name), log name + chained cause, and remove/fix that preset before restart.
Prevention
- Fully specify presets from documented examples
- Test preset rendering on the /themes page in staging
- Keep fork template edits in sync with struct fields
When it happens
Trigger: Executing the preview template with a themeProperties value containing fields in an invalid state (colors, multipliers); preset previews are generated for every preset, so any one bad preset in theme.presets triggers it (wrapped as 'initializing preset theme %s').
Common situations: Custom presets with exotic values; fork modifications to the preview template; theme fields partially specified leaving zero-value structs the template mishandles.
Related errors
- compiling theme style: %v
- initializing preset theme %s: %v
- initializing default theme: %v
- URL is required
- nested groups are not supported
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/b74f90355cf8cb17.
Report an issue: GitHub.