algolia / algoliasearch-client-python

⚡️ A fully-featured and blazing-fast Python API client to interact with Algolia.
https://www.algolia.com/doc/api-client/getting-started/install/python/?language=python
MIT License
196 stars 67 forks source link

Add quick check to PaginatorIterator to check if the hits dictionary … #545

Closed ryancambray-ct closed 1 year ago

ryancambray-ct commented 2 years ago

…contains the element '_highlightResult'

This is to avoid the iterators file throwing a KeyError when the element does not contain this.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Related Issue Fix #544
Need Doc update yes/no

Describe your change

Checks if the hit element contains the key '_highlightResult' before removing it from the element.

What problem is this fixing?

When batch saving rules called from the browse_rules API call, the RuleIterator throws a KeyError if the rule element does not contain the key '_highlightResult'. This is a rare occurrence but it is possible.