Skip to content

Commit

Permalink
fix(api/categories): fix custom sync via http will raise IndexError i…
Browse files Browse the repository at this point in the history
…f results is empty (#410)

fix #390
  • Loading branch information
wklken committed May 9, 2022
1 parent 6234477 commit 10d97f1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/api/bkuser_core/categories/plugins/custom/client.py
Expand Up @@ -72,6 +72,12 @@ def _fetch_items(self, path: str):
logger.error("`results` in response is not a list, cUrl format: %s", curl_format)
raise CustomAPIRequestFailed("the `results` in response is not a list")

# currently, if the results is empty, CustomTypeList.custom_type will raise IndexError(task fail)
# so, here, we should check here: results size should not be empty
if not results:
logger.error("`results` in response is empty, cUrl format: %s", curl_format)
raise CustomAPIRequestFailed("the `results` in response is empty")

return results

def fetch_profiles(self, page_info: Optional[PageInfo] = None) -> CustomTypeList:
Expand Down

0 comments on commit 10d97f1

Please sign in to comment.