glanceapp/glance · error

no place found for %s in %s

Error message

no place found for %s in %s

What it means

The geocoder returned results for the base name, but none whose Area matched the qualifier the user supplied (e.g. 'Springfield, Missouri' when all matches are in other states/countries). After the area-filter loop, place is still nil, so the widget refuses to guess.

Source

Thrown at internal/glance/widget-weather.go:197

	if len(responseJson.Results) == 0 {
		return nil, fmt.Errorf("no places found for %s", location)
	}

	var place *openMeteoPlaceResponseJson

	if area != "" {
		area = strings.ToLower(area)

		for i := range responseJson.Results {
			if strings.ToLower(responseJson.Results[i].Area) == area {
				place = &responseJson.Results[i]
				break
			}
		}

		if place == nil {
			return nil, fmt.Errorf("no place found for %s in %s", location, area)
		}
	} else {
		place = &responseJson.Results[0]
	}

	loc, err := time.LoadLocation(place.Timezone)
	if err != nil {
		return nil, fmt.Errorf("loading location: %v", err)
	}

	place.location = loc

	return place, nil
}

func fetchWeatherForOpenMeteoPlace(place *openMeteoPlaceResponseJson, units string) (*weather, error) {
	query := url.Values{}
	var temperatureUnit string

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Query the API with the base name and inspect the area field of each result to see the exact expected string
  2. Match the area spelling to what the geocoder returns (full state/country name, not abbreviation)
  3. Drop the qualifier if the unqualified first result is the right place

Example fix

# before
location: Portland, OR

# after
location: Portland, Oregon
Defensive patterns

Strategy: validation

Validate before calling

// Verify an area-qualified location has a matching result before deploy
func areaQualifierMatches(name, area string) bool {
    u := fmt.Sprintf("https://geocoding-api.open-meteo.com/v1/search?name=%s&count=20&language=en&format=json", url.QueryEscape(name))
    resp, err := http.Get(u)
    if err != nil { return false }
    defer resp.Body.Close()
    var r struct{ Results []struct{ Area string `json:"admin1"` } `json:"results"` }
    _ = json.NewDecoder(resp.Body).Decode(&r)
    for _, res := range r.Results {
        if strings.EqualFold(res.Area, area) { return true }
    }
    return false
}

Type guard

func isNoPlaceInArea(err error) bool {
	return err != nil && strings.HasPrefix(err.Error(), "no place found for")
}

Try / catch

place, err := fetchOpenMeteoPlaceFromName(cfg.Location)
if isNoPlaceInArea(err) {
    return fmt.Errorf("location %q does not match geocoder areas: %w", cfg.Location, err)
}

Prevention

When it happens

Trigger: An area-qualified location where the lowercase area never equals any Results[i].Area: wrong area name, wrong separator, or a genuinely absent combination.

Common situations: Users write 'City, State' with a state the geocoder lists under a different string ('Missouri' vs 'MO'), or use abbreviations the API does not return, or pick a city not present in that area at all.

Related errors


AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15). Data as JSON: /api/errors/6a08fef797965356. Report an issue: GitHub.