{"record":{"id":"2660f4f338573eaf","repo":"JanDeDobbeleer/oh-my-posh","slug":"no-location-found","errorCode":null,"errorMessage":"no location found","messagePattern":"no location found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/segments/owm.go","lineNumber":71,"sourceCode":"\n\treturn true\n}\n\nfunc (d *Owm) Template() string {\n\treturn \" {{ .Weather }} ({{ .Temperature }}{{ .UnitIcon }}) \"\n}\n\nfunc (d *Owm) getResult() (*owmDataResponse, error) {\n\tresponse := new(owmDataResponse)\n\n\tapikey := d.options.Template(APIKey, \"\", d)\n\tif apikey == \"\" {\n\t\treturn nil, errors.New(\"no api key found\")\n\t}\n\n\tlocation := d.options.Template(Location, \"\", d)\n\tif location == \"\" {\n\t\treturn nil, errors.New(\"no location found\")\n\t}\n\n\tlocation = url.QueryEscape(location)\n\n\tunits := d.options.String(Units, \"standard\")\n\thttpTimeout := d.options.Int(options.HTTPTimeout, options.DefaultHTTPTimeout)\n\n\td.URL = fmt.Sprintf(\"https://api.openweathermap.org/data/2.5/weather?q=%s&units=%s&appid=%s\", location, units, apikey)\n\n\tbody, err := d.env.HTTPRequest(d.URL, nil, httpTimeout)\n\tif err != nil {\n\t\treturn new(owmDataResponse), err\n\t}\n\n\terr = json.Unmarshal(body, &response)\n\tif err != nil {\n\t\treturn new(owmDataResponse), err\n\t}","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/owm.go#L53-L89","documentation":"The OpenWeatherMap segment requires the location option. getResult validates it (as a rendered template) before calling the API and fails with this error when it is empty, since OWM's q= parameter needs a city name to geocode.","triggerScenarios":"Configuring an owm segment with no location, location = \"\", or a location template that renders empty (e.g. {{ .Env.WEATHER_CITY }} unset); also empty after template expansion even if a raw value was provided.","commonSituations":"Themes that leave location to the user's edit, switching from a weather provider that used coordinates to OWM which expects a city string, or relying on an env var that was never exported.","solutions":["Set location to a city name, optionally with country code, e.g. \"Berlin,DE\".","If location is a template, verify it renders non-empty (check the referenced env/property).","Alternatively use the openweather segment which supports latitude/longitude if a city string is impractical.","URL-hostile characters are fine — the segment query-escapes the value — so the issue is emptiness, not formatting."],"exampleFix":"// before\n\"type\": \"owm\",\n\"api_key\": \"...\"\n// after\n\"type\": \"owm\",\n\"api_key\": \"...\",\n\"location\": \"Amsterdam,NL\"","handlingStrategy":"validation","validationCode":"const loc = cfg.location?.trim()\nif (!loc) {\n  throw new Error(\"owm segment requires a non-empty location, e.g. 'Berlin,DE'\")\n}","typeGuard":null,"tryCatchPattern":"if err := d.setStatus(); err != nil {\n  if err.Error() == \"no location found\" {\n    log.Warn(\"owm: set location in segment config\")\n    return // hide segment\n  }\n  return err\n}","preventionTips":["Set location as \"City,CC\" (optionally with country code) in the owm config.","If location is a template, confirm it renders non-empty at runtime.","When migrating between weather providers, remember OWM uses a city string, not lat/lng.","Validate the theme config against the schema which documents the location option."],"tags":["config","openweathermap","weather","missing-option"],"backgroundTag":"missing-config-option","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}