glanceapp/glance · error
HSL lightness must be between 0 and %d
Error message
HSL lightness must be between 0 and %d
What it means
Returned by hslColorField.UnmarshalYAML when the lightness component of an HSL color string exceeds hslLightnessMax (100) after parsing as float. Third and final range check in HSL color parsing; fires after pattern match and successful float parse of matches[3].
Source
Thrown at internal/glance/config-fields.go:86
return fmt.Errorf("HSL hue must be between 0 and %d", hslHueMax)
}
saturation, err := strconv.ParseFloat(matches[2], 64)
if err != nil {
return err
}
if saturation > hslSaturationMax {
return fmt.Errorf("HSL saturation must be between 0 and %d", hslSaturationMax)
}
lightness, err := strconv.ParseFloat(matches[3], 64)
if err != nil {
return err
}
if lightness > hslLightnessMax {
return fmt.Errorf("HSL lightness must be between 0 and %d", hslLightnessMax)
}
c.H = hue
c.S = saturation
c.L = lightness
return nil
}
var durationFieldPattern = regexp.MustCompile(`^(\d+)(s|m|h|d)$`)
type durationField time.Duration
func (d *durationField) UnmarshalYAML(node *yaml.Node) error {
var value string
if err := node.Decode(&value); err != nil {
return errView on GitHub (pinned to 91324e8de7)
Solutions
- Keep lightness between 0% and 100%.
- Fix typos in the third component.
- Run `glance config:validate` to pinpoint the key.
Example fix
# before primary-color: 200 50% 120% # after primary-color: 200 50% 45%
Defensive patterns
Strategy: validation
Validate before calling
python3 -c "
import re,sys
hsl=re.compile(r'^(\d+(?:\.\d+)?) (\d+(?:\.\d+)?)% (\d+(?:\.\d+)?)%$')
m=hsl.match('200 50% 120%')
sys.exit('lightness out of range' if m and float(m.group(3))>100 else 0)
" Prevention
- Keep lightness on the 0-100% scale.
- Run a config lint for all three HSL components in CI.
When it happens
Trigger: An HSL color such as `200 50% 120%` — lightness above 100%.
Common situations: Same as other range errors: values ported from different scales, typos, or copy-paste from tools that normalize differently.
Related errors
- HSL hue must be between 0 and %d
- HSL saturation must be between 0 and %d
- invalid HSL color format: %s
- URL is required
- nested groups are not supported
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/07e205763dbfa329.
Report an issue: GitHub.