{"record":{"id":"12ff42eb88a18d8a","repo":"glanceapp/glance","slug":"location-is-required","errorCode":null,"errorMessage":"location is required","messagePattern":"location is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-weather.go","lineNumber":39,"sourceCode":"\twidgetBase   `yaml:\",inline\"`\n\tLocation     string                      `yaml:\"location\"`\n\tShowAreaName bool                        `yaml:\"show-area-name\"`\n\tHideLocation bool                        `yaml:\"hide-location\"`\n\tHourFormat   string                      `yaml:\"hour-format\"`\n\tUnits        string                      `yaml:\"units\"`\n\tPlace        *openMeteoPlaceResponseJson `yaml:\"-\"`\n\tWeather      *weather                    `yaml:\"-\"`\n\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}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-weather.go#L21-L57","documentation":"Config validation in the weather widget's initialize(): the location field is empty. The widget cannot geocode or fetch a forecast without it, so initialization fails fast with a clear message rather than producing an empty widget.","triggerScenarios":"A weather widget block in glance.yml with no location key, or location set to an empty string / null.","commonSituations":"Copy-pasting a widget template and forgetting to fill in location; YAML indentation placing location under the wrong key so it is never parsed.","solutions":["Add location: \"City, Country\" to the weather widget in glance.yml","Check YAML indentation — location must be a direct child of the weather widget mapping","Validate the config with a YAML linter if the field seems present but is ignored"],"exampleFix":"# before\n- type: weather\n  # location missing\n\n# after\n- type: weather\n  location: Amsterdam, Netherlands","handlingStrategy":"validation","validationCode":"// before writing glance.yml, assert every weather widget has a location\nfunc validateWeatherWidgets(pages []PageConfig) error {\n    for _, p := range pages {\n        for _, w := range p.Widgets {\n            if w.Type == \"weather\" && strings.TrimSpace(w.Location) == \"\" {\n                return fmt.Errorf(\"weather widget on page %q missing location\", p.Name)\n            }\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := widget.initialize(); err != nil {\n    if strings.Contains(err.Error(), \"location is required\") {\n        // config authoring mistake: fail fast with the widget's name in the message\n        return fmt.Errorf(\"weather widget: %w\", err)\n    }\n}","preventionTips":["Lint glance.yml in CI with a schema that marks weather.location as required","Copy from a known-good example in the docs rather than from memory"],"tags":["weather","config","validation","yaml"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}