{"record":{"id":"dd465c2cbdac1014","repo":"glanceapp/glance","slug":"units-must-be-either-metric-or-imperial","errorCode":null,"errorMessage":"units must be either metric or imperial","messagePattern":"units must be either metric or imperial","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-weather.go","lineNumber":53,"sourceCode":"func (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}\n\n\t\twidget.Place = place\n\t}\n\n\tweather, err := fetchWeatherForOpenMeteoPlace(widget.Place, widget.Units)\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-weather.go#L35-L71","documentation":"Returned by weatherWidget.initialize() when the weather widget's units value is neither empty, 'metric', nor 'imperial'. The field controls whether Open-Meteo forecasts render in °C/mm vs °F/inches. It fails fast at config-load time, wrapped as 'weather widget: units must be either metric or imperial'.","triggerScenarios":"YAML config has a weather widget with units: celsius, units: fahrenheit, units: Metric (capitalized), units: SI, or any other string — only '', 'metric', 'imperial' are accepted.","commonSituations":"Intuitively writing 'celsius'/'fahrenheit' instead of the unit system name; capitalized 'Metric'; copying config snippets from blog posts that use wrong values.","solutions":["Use units: metric or units: imperial exactly, or omit the key (defaults to metric).","Run `glance config:validate --config glance.yml` after editing to catch it before restart.","Double-check YAML quoting and casing."],"exampleFix":"// glance.yml (before)\n- type: weather\n  location: Tokyo, Japan\n  units: celsius\n\n// after\n- type: weather\n  location: Tokyo, Japan\n  units: metric","handlingStrategy":"validation","validationCode":"grep -n 'units:' glance.yml | grep -vE 'units:\\s*(metric|imperial)\\s*$' && echo 'BAD units' && exit 1 || echo ok","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only 'metric' or 'imperial' (or omit for metric default).","Never write temperature-scale names like celsius/fahrenheit.","Validate config with `glance config:validate` before restart."],"tags":["config","weather","validation","units"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}