JanDeDobbeleer/oh-my-posh · error

no data found

Error message

no data found

What it means

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.

Source

Thrown at src/segments/owm.go:103

	err = json.Unmarshal(body, &response)
	if err != nil {
		return new(owmDataResponse), err
	}

	return response, nil
}

func (d *Owm) setStatus() error {
	units := d.options.String(Units, "standard")

	q, err := d.getResult()
	if err != nil {
		return err
	}

	if len(q.Data) == 0 {
		return errors.New("no data found")
	}

	id := q.Data[0].TypeID

	d.Temperature = int(math.Round(q.Value))
	icon := ""
	switch id {
	case "01n":
		icon = "\ue32b"
	case "01d":
		icon = "\ue30d"
	case "02n":
		icon = "\ue37e"
	case "02d":
		icon = "\ue302"
	case "03n":
		fallthrough
	case "03d":

View on GitHub (pinned to 0976794618)

Solutions

  1. 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.
  2. Verify the location string resolves on OWM (try a simpler "City,CC").
  3. Inspect for rate-limit or 401 messages in the raw response; fix auth/quota accordingly.
  4. If the API response shape changed, update to a maintained version of oh-my-posh.
  5. Confirm units option is one of standard/metric/imperial to avoid an API rejection.

Example fix

// before
curl 'https://api.openweathermap.org/data/2.5/weather?q=Nowhere&appid=OLDKEY'
// after
curl 'https://api.openweathermap.org/data/2.5/weather?q=London,UK&appid=VALID_KEY'
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch(`https://api.openweathermap.org/data/2.5/weather?q=${loc}&appid=${key}`)
const body = await res.json()
if (!res.ok || !Array.isArray(body.weather) || body.weather.length === 0) {
  throw new Error(`OWM rejected the request (HTTP ${res.status}): ${JSON.stringify(body)}`)
}

Type guard

function hasWeatherData(resp) {
  return resp != null && Array.isArray(resp.weather) && resp.weather.length > 0 && resp.main?.temp !== undefined
}

Try / catch

if err := d.setStatus(); err != nil {
  if err.Error() == "no data found" {
    log.Warn("owm: API returned no weather array; check key/location via curl")
    return // hide segment
  }
  return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/6de3c9fd188cdcfa. Report an issue: GitHub.