glanceapp/glance · error
invalid HSL color format: %s
Error message
invalid HSL color format: %s
What it means
Returned by hslColorField.UnmarshalYAML when a YAML value destined for an HSL color field (e.g. theme colors like primary-color) does not match the expected 'H S% L%' pattern. The regex hslColorFieldPattern expects 3 capture groups (hue, saturation, lightness); a FindStringSubmatch result of any length other than 4 (full match + 3 groups) triggers this error with the offending value echoed back.
Source
Thrown at internal/glance/config-fields.go:59
return true
}
if c1 == nil || c2 == nil {
return false
}
return c1.H == c2.H && c1.S == c2.S && c1.L == c2.L
}
func (c *hslColorField) UnmarshalYAML(node *yaml.Node) error {
var value string
if err := node.Decode(&value); err != nil {
return err
}
matches := hslColorFieldPattern.FindStringSubmatch(value)
if len(matches) != 4 {
return fmt.Errorf("invalid HSL color format: %s", value)
}
hue, err := strconv.ParseFloat(matches[1], 64)
if err != nil {
return err
}
if hue > hslHueMax {
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)View on GitHub (pinned to 91324e8de7)
Solutions
- Use the exact HSL form without parentheses: `primary-color: 200 50% 40%` (hue 0-360, saturation and lightness with %).
- Convert hex colors to HSL before putting them in theme config (Glance theme color fields take HSL, not hex).
- Validate with `glance config:validate` to locate the offending key.
Example fix
# glance.yml (before) theme: primary-color: #3442bb # after theme: primary-color: 232 55% 47%
Defensive patterns
Strategy: validation
Validate before calling
python3 - <<'EOF'
import re,sys
pat=re.compile(r'^\d+(\.\d+)? \d+(\.\d+)?% \d+(\.\d+)?%$')
for line in open('glance.yml'):
if re.search(r'-(\s*\w+-?color):',line):
key,val=line.split(':',1)
if val.strip() and not pat.match(val.strip()):
sys.exit(f'bad HSL: {line.strip()}')
print('ok')
EOF Prevention
- Memorize the Glance HSL form: 'H S% L%' with no hsl() wrapper.
- Convert hex to HSL with a converter before pasting into theme config.
- Validate config after every theme tweak.
When it happens
Trigger: Writing primary-color: #ff0000 (hex), primary-color: red, primary-color: 200 50 (missing lightness), or hsl(200, 50%, 40%) with wrong punctuation/spacing; any string the HSL regex cannot fully match.
Common situations: Mixing up hex and HSL formats between theme keys; copying hex colors from a design tool; missing the % sign on saturation/lightness; extra spaces or commas the pattern doesn't allow.
Related errors
- HSL hue must be between 0 and %d
- HSL saturation must be between 0 and %d
- HSL lightness must be between 0 and %d
- URL is required
- nested groups are not supported
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/3ded4eea7ee544d0.
Report an issue: GitHub.