{"record":{"id":"6de3c9fd188cdcfa","repo":"JanDeDobbeleer/oh-my-posh","slug":"no-data-found-6de3c9","errorCode":null,"errorMessage":"no data found","messagePattern":"no data found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/segments/owm.go","lineNumber":103,"sourceCode":"\n\terr = json.Unmarshal(body, &response)\n\tif err != nil {\n\t\treturn new(owmDataResponse), err\n\t}\n\n\treturn response, nil\n}\n\nfunc (d *Owm) setStatus() error {\n\tunits := d.options.String(Units, \"standard\")\n\n\tq, err := d.getResult()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(q.Data) == 0 {\n\t\treturn errors.New(\"no data found\")\n\t}\n\n\tid := q.Data[0].TypeID\n\n\td.Temperature = int(math.Round(q.Value))\n\ticon := \"\"\n\tswitch id {\n\tcase \"01n\":\n\t\ticon = \"\\ue32b\"\n\tcase \"01d\":\n\t\ticon = \"\\ue30d\"\n\tcase \"02n\":\n\t\ticon = \"\\ue37e\"\n\tcase \"02d\":\n\t\ticon = \"\\ue302\"\n\tcase \"03n\":\n\t\tfallthrough\n\tcase \"03d\":","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/owm.go#L85-L121","documentation":"setStatus reached the point where the OWM API responded with parseable JSON, but the weather array in the response was empty (len(q.Data) == 0), so no condition icon or description can be derived. This typically means the API answered successfully but with a payload lacking the weather field — most often an OWM error body (e.g. 401/404 JSON) that unmarshals without the weather array rather than a real forecast.","triggerScenarios":"getResult got an HTTP response and unmarshalled it, but response.weather is absent or empty — invalid API key returning {\"cod\":401,...}, unknown location returning 404, or an upstream API change to the response shape.","commonSituations":"Expired or revoked OWM API keys (new keys take a couple of hours to activate), misspelled city names, free-tier key used against a paid endpoint, or OWM schema changes.","solutions":["Check the API key is valid and activated (new OWM keys can take hours); test the built URL with curl and inspect the response body.","Verify the location string resolves on OWM (try a simpler \"City,CC\").","Inspect for rate-limit or 401 messages in the raw response; fix auth/quota accordingly.","If the API response shape changed, update to a maintained version of oh-my-posh.","Confirm units option is one of standard/metric/imperial to avoid an API rejection."],"exampleFix":"// before\ncurl 'https://api.openweathermap.org/data/2.5/weather?q=Nowhere&appid=OLDKEY'\n// after\ncurl 'https://api.openweathermap.org/data/2.5/weather?q=London,UK&appid=VALID_KEY'","handlingStrategy":"try-catch","validationCode":"const res = await fetch(`https://api.openweathermap.org/data/2.5/weather?q=${loc}&appid=${key}`)\nconst body = await res.json()\nif (!res.ok || !Array.isArray(body.weather) || body.weather.length === 0) {\n  throw new Error(`OWM rejected the request (HTTP ${res.status}): ${JSON.stringify(body)}`)\n}","typeGuard":"function hasWeatherData(resp) {\n  return resp != null && Array.isArray(resp.weather) && resp.weather.length > 0 && resp.main?.temp !== undefined\n}","tryCatchPattern":"if err := d.setStatus(); err != nil {\n  if err.Error() == \"no data found\" {\n    log.Warn(\"owm: API returned no weather array; check key/location via curl\")\n    return // hide segment\n  }\n  return err\n}","preventionTips":["Validate the API key with curl before configuring — new OWM keys take a few hours to activate.","Confirm the location resolves on OWM (misspellings yield 404 bodies with no weather array).","Watch OWM API changelogs; upgrade oh-my-posh if the response schema changes.","Handle rate limits/quota exhaustion gracefully rather than treating them as config bugs."],"tags":["openweathermap","api","weather","empty-response"],"backgroundTag":"empty-response-body","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}