From 6eb272074b2b65ebafb4e9137429f4ed30cf26d2 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Fri, 29 Sep 2023 16:38:02 -0400 Subject: [PATCH] safeguard missing properties during .../items queries using properties= (#1356) --- pygeoapi/provider/elasticsearch_.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pygeoapi/provider/elasticsearch_.py b/pygeoapi/provider/elasticsearch_.py index ad34ece..2b146e1 100644 --- a/pygeoapi/provider/elasticsearch_.py +++ b/pygeoapi/provider/elasticsearch_.py @@ -463,9 +463,10 @@ class ElasticsearchProvider(BaseProvider): LOGGER.debug('Fetching id and geometry from GeoJSON document') feature_ = doc['_source'] - if self.id_field in doc['_source']['properties']: + try: id_ = doc['_source']['properties'][self.id_field] - else: + except KeyError as err: + LOGGER.debug(f'Missing field: {err}') id_ = doc['_source'].get('id', doc['_id']) feature_['id'] = id_