Skip to content

Commit 6cc662f

Browse files
Merge pull request #3 from reloc8/bugfix/index-out-of-bounds
Fix possible index out of bounds
2 parents 7223978 + bb65caf commit 6cc662f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

geocode_property/core/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ def geocode_property(self, property: Dict[AnyStr, Any]) -> Dict[AnyStr, Any]:
5050
status_code = response.status
5151
if status_code == 200:
5252
data = json.loads(response.data)
53-
best_result = data['features'][0]
54-
latitude = best_result['center'][1]
55-
longitude = best_result['center'][0]
53+
results = data['features']
54+
if results and isinstance(results, list):
55+
best_result = results[0]
56+
latitude = best_result['center'][1]
57+
longitude = best_result['center'][0]
5658
else:
5759
self.logger.error(f'Received response with unexpected status: {status_code}')
5860
else:

0 commit comments

Comments
 (0)