{"record":{"id":"0f07f78293dc7628","repo":"glanceapp/glance","slug":"hour-format-must-be-either-12h-or-24h-0f07f7","errorCode":null,"errorMessage":"hour-format must be either 12h or 24h","messagePattern":"hour-format must be either 12h or 24h","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-weather.go","lineNumber":47,"sourceCode":"\tTimeLabels   [12]string                  `yaml:\"-\"`\n}\n\nvar timeLabels12h = [12]string{\"2am\", \"4am\", \"6am\", \"8am\", \"10am\", \"12pm\", \"2pm\", \"4pm\", \"6pm\", \"8pm\", \"10pm\", \"12am\"}\nvar timeLabels24h = [12]string{\"02:00\", \"04:00\", \"06:00\", \"08:00\", \"10:00\", \"12:00\", \"14:00\", \"16:00\", \"18:00\", \"20:00\", \"22:00\", \"00:00\"}\n\nfunc (widget *weatherWidget) initialize() error {\n\twidget.withTitle(\"Weather\").withCacheOnTheHour()\n\n\tif widget.Location == \"\" {\n\t\treturn fmt.Errorf(\"location is required\")\n\t}\n\n\tif widget.HourFormat == \"\" || widget.HourFormat == \"12h\" {\n\t\twidget.TimeLabels = timeLabels12h\n\t} else if widget.HourFormat == \"24h\" {\n\t\twidget.TimeLabels = timeLabels24h\n\t} else {\n\t\treturn errors.New(\"hour-format must be either 12h or 24h\")\n\t}\n\n\tif widget.Units == \"\" {\n\t\twidget.Units = \"metric\"\n\t} else if widget.Units != \"metric\" && widget.Units != \"imperial\" {\n\t\treturn errors.New(\"units must be either metric or imperial\")\n\t}\n\n\treturn nil\n}\n\nfunc (widget *weatherWidget) update(ctx context.Context) {\n\tif widget.Place == nil {\n\t\tplace, err := fetchOpenMeteoPlaceFromName(widget.Location)\n\t\tif err != nil {\n\t\t\twidget.withError(err).scheduleEarlyUpdate()\n\t\t\treturn\n\t\t}","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-weather.go#L29-L65","documentation":"Returned by weatherWidget.initialize() during config parsing when the twitch weather widget's hour-format value is neither empty, '12h', nor '24h'. The field selects which hour labels the hourly forecast uses; anything else is rejected at startup so the config author notices immediately. The error is wrapped by formatWidgetInitError into 'weather widget: hour-format must be either 12h or 24h'.","triggerScenarios":"YAML config contains a widget of type weather with hour-format set to e.g. '12H', '24', '12-hour', 'h12', or any typo — any string other than '', '12h', '24h' hits the else branch and errors.","commonSituations":"Copy-pasting config from docs that use a different casing; writing '24H' uppercase; assuming 'h:24' or numeric 24 is accepted; hand-editing glance.yml and forgetting the exact allowed literals.","solutions":["Set hour-format: 12h or hour-format: 24h exactly (lowercase, with the h suffix), or remove the key entirely to default to 12h.","Validate the whole file before serving with `glance config:validate --config glance.yml` (or `glance config:print`) to catch typos.","Check for stray quoting/casing in YAML (e.g. '24H') and correct it."],"exampleFix":"// glance.yml (before)\n- type: weather\n  location: Berlin, Germany\n  hour-format: 24H\n\n// after\n- type: weather\n  location: Berlin, Germany\n  hour-format: 24h","handlingStrategy":"validation","validationCode":"# in CI or a pre-deploy hook:\ngrep -n 'hour-format:' glance.yml | grep -vE 'hour-format:\\s*(12h|24h)\\s*$' && echo 'BAD hour-format' && exit 1 || echo ok","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use '12h' or '24h' (or omit) — copy from the official docs.","Run `glance config:validate` in CI for every config change."],"tags":["config","weather","validation","yaml"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}