{"record":{"id":"b74f90355cf8cb17","repo":"glanceapp/glance","slug":"compiling-theme-preview-v","errorCode":null,"errorMessage":"compiling theme preview: %v","messagePattern":"compiling theme preview: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/theme.go","lineNumber":65,"sourceCode":"\tContrastMultiplier       float32        `yaml:\"contrast-multiplier\"`\n\tTextSaturationMultiplier float32        `yaml:\"text-saturation-multiplier\"`\n\n\tKey                  string        `yaml:\"-\"`\n\tCSS                  template.CSS  `yaml:\"-\"`\n\tPreviewHTML          template.HTML `yaml:\"-\"`\n\tBackgroundColorAsHex string        `yaml:\"-\"`\n}\n\nfunc (t *themeProperties) init() error {\n\tcss, err := executeTemplateToString(themeStyleTemplate, t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"compiling theme style: %v\", err)\n\t}\n\tt.CSS = template.CSS(whitespaceAtBeginningOfLinePattern.ReplaceAllString(css, \"\"))\n\n\tpreviewHTML, err := executeTemplateToString(themePresetPreviewTemplate, t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"compiling theme preview: %v\", err)\n\t}\n\tt.PreviewHTML = template.HTML(previewHTML)\n\n\tif t.BackgroundColor != nil {\n\t\tt.BackgroundColorAsHex = t.BackgroundColor.ToHex()\n\t} else {\n\t\tt.BackgroundColorAsHex = \"#151519\"\n\t}\n\n\treturn nil\n}\n\nfunc (t1 *themeProperties) SameAs(t2 *themeProperties) bool {\n\tif t1 == nil && t2 == nil {\n\t\treturn true\n\t}\n\tif t1 == nil || t2 == nil {\n\t\treturn false","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/theme.go#L47-L83","documentation":"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.","triggerScenarios":"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').","commonSituations":"Custom presets with exotic values; fork modifications to the preview template; theme fields partially specified leaving zero-value structs the template mishandles.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure every preset supplies required renderable fields (e.g. colors present or omitted consistently)\nfor _, p := range presets {\n    if p.ColorScheme != \"\" && !validColorScheme(p.ColorScheme) { return fmt.Errorf(\"invalid color-scheme in preset\") }\n    if !validMultiplier(p.ContrastMultiplier) { return fmt.Errorf(\"invalid multiplier in preset\") }\n}\n","typeGuard":null,"tryCatchPattern":"Catch at preset init (message includes the preset name), log name + chained cause, and remove/fix that preset before restart.","preventionTips":["Fully specify presets from documented examples","Test preset rendering on the /themes page in staging","Keep fork template edits in sync with struct fields"],"tags":["themes","template","html","validation"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}