]> git.openstreetmap.org Git - nominatim.git/commit
Return empty result list for category searches without matches
authorItz-Agasta <rupamgolui69@gmail.com>
Sat, 25 Jul 2026 18:21:29 +0000 (23:51 +0530)
committerItz-Agasta <rupamgolui69@gmail.com>
Sat, 25 Jul 2026 18:21:29 +0000 (23:51 +0530)
commit854beb8b6878bfb5f9a92298d40a94b7101bd78f
treea85cccaa665775909914ce5c08efb9d05cf8da7b
parent2991c61bf2028d6a53acc09593f20aaaad0b5d68
Return empty result list for category searches without matches

A /search request using the [key=value] category syntax together with a
near-phrase crashed with a 500 error whenever the search legitimately
found nothing.

Two places in ForwardGeocoder.lookup_pois() indexed into an empty list:

* sort_and_cut_results() accessed results[0] without checking that any
  results were found. The guard was lost in 87a8c246.
* execute_searches() accessed searches[0] when the near-phrase produced
  no search interpretations at all. lookup_pois() guarded this with
  'if query', which is always true because QueryStruct has no __bool__.
  Use 'if searches' instead, as lookup() already does.

Fixes #4148
src/nominatim_api/search/geocoder.py
test/bdd/features/api/search/queries.feature