{"record":{"id":"3ded4eea7ee544d0","repo":"glanceapp/glance","slug":"invalid-hsl-color-format-s","errorCode":null,"errorMessage":"invalid HSL color format: %s","messagePattern":"invalid HSL color format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/config-fields.go","lineNumber":59,"sourceCode":"\t\treturn true\n\t}\n\tif c1 == nil || c2 == nil {\n\t\treturn false\n\t}\n\treturn c1.H == c2.H && c1.S == c2.S && c1.L == c2.L\n}\n\nfunc (c *hslColorField) UnmarshalYAML(node *yaml.Node) error {\n\tvar value string\n\n\tif err := node.Decode(&value); err != nil {\n\t\treturn err\n\t}\n\n\tmatches := hslColorFieldPattern.FindStringSubmatch(value)\n\n\tif len(matches) != 4 {\n\t\treturn fmt.Errorf(\"invalid HSL color format: %s\", value)\n\t}\n\n\thue, err := strconv.ParseFloat(matches[1], 64)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif hue > hslHueMax {\n\t\treturn fmt.Errorf(\"HSL hue must be between 0 and %d\", hslHueMax)\n\t}\n\n\tsaturation, err := strconv.ParseFloat(matches[2], 64)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif saturation > hslSaturationMax {\n\t\treturn fmt.Errorf(\"HSL saturation must be between 0 and %d\", hslSaturationMax)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/config-fields.go#L41-L77","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# glance.yml (before)\ntheme:\n  primary-color: #3442bb\n\n# after\ntheme:\n  primary-color: 232 55% 47%","handlingStrategy":"validation","validationCode":"python3 - <<'EOF'\nimport re,sys\npat=re.compile(r'^\\d+(\\.\\d+)? \\d+(\\.\\d+)?% \\d+(\\.\\d+)?%$')\nfor line in open('glance.yml'):\n    if re.search(r'-(\\s*\\w+-?color):',line):\n        key,val=line.split(':',1)\n        if val.strip() and not pat.match(val.strip()):\n            sys.exit(f'bad HSL: {line.strip()}')\nprint('ok')\nEOF","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["config","theme","color","yaml","validation"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}