sqshq/sampler · error

Specified theme is not supported: %v

Error message

Specified theme is not supported: %v

What it means

GetPalette switches on the Theme enum and panics in the default branch when the theme value is not one of the supported constants (e.g. ThemeDark/ThemeLight). Since Theme is parsed from the YAML as a string, an unrecognized theme name produces this panic at startup.

Source

Thrown at console/palette.go:70

	switch theme {
	case ThemeDark:
		return Palette{
			ContentColors:  []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGrey, ColorGreen, ColorOrange, ColorCian, ColorPurple},
			GradientColors: [][]ui.Color{{39, 33, 62, 93, 164, 161}, {95, 138, 180, 179, 178, 178}},
			BaseColor:      ColorWhite,
			MediumColor:    ColorDarkGrey,
			ReverseColor:   ColorBlack,
		}
	case ThemeLight:
		return Palette{
			ContentColors:  []ui.Color{ColorBlack, ColorDarkRed, ColorBlueViolet, ColorGrey, ColorGreen},
			GradientColors: [][]ui.Color{{250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 16}},
			BaseColor:      ColorBlack,
			MediumColor:    ColorLightGrey,
			ReverseColor:   ColorWhite,
		}
	default:
		panic(fmt.Sprintf("Specified theme is not supported: %v", theme))
	}
}

// GetMenuColor returns a color based on the
// operating system target
func GetMenuColor() ui.Color {
	switch runtime.GOOS {
	case "windows":
		return menuColorWindows
	default:
		return menuColorNix
	}
}

// GetMenuColorReverse returns a color based on the
// operating system target
func GetMenuColorReverse() ui.Color {
	switch runtime.GOOS {

View on GitHub (pinned to 9bc7ba732d)

Solutions

  1. Set theme to a supported value (dark or light) in the config
  2. Validate the theme string against known values during config load and fall back to defaultTheme on mismatch
  3. Handle the panic with recover if themes should be non-fatal, or add a validation step in config parsing
  4. Check the Theme type's constants for the exact accepted names

Example fix

// before
theme: darck
// after
theme: dark
Defensive patterns

Strategy: validation

Validate before calling

switch cfg.Theme {
case "", "dark", "light":
default:
    log.Printf("unknown theme %q, using dark", cfg.Theme)
    cfg.Theme = "dark"
}

Type guard

func validTheme(t console.Theme) bool { return t == console.ThemeDark || t == console.ThemeLight }

Try / catch

func paletteSafe(theme console.Theme) (p console.Palette, err error) {
    defer func() { if r := recover(); r != nil { err = fmt.Errorf("bad theme: %v", r) } }()
    return console.GetPalette(theme), nil
}

Prevention

When it happens

Trigger: Passing a console.Theme value outside the supported set to GetPalette — typically from a config file with theme: <unknown string>, or constructing Theme from raw YAML bytes without prior validation.

Common situations: Typo in the YAML theme key (e.g. "darck", "dark "); config from an older/newer version with a renamed theme; programmatically casting an arbitrary string to console.Theme.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of sqshq/sampler@9bc7ba732d (2026-09-06). Data as JSON: /api/errors/89e5c4d26fd2f11e. Report an issue: GitHub.