From 26f318e170b1d3e154e395092c9c764acc79bd4e Mon Sep 17 00:00:00 2001 From: Alex Garel Date: Fri, 25 Mar 2022 09:18:33 +0100 Subject: [PATCH] fix: fetch_taxonomy should check response status --- robotoff/taxonomy.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/robotoff/taxonomy.py b/robotoff/taxonomy.py index ce93ed5b30..e66cf724a1 100644 --- a/robotoff/taxonomy.py +++ b/robotoff/taxonomy.py @@ -5,6 +5,7 @@ from typing import Dict, Iterable, List, Optional, Set, Union import orjson +import requests from robotoff import settings from robotoff.utils import get_logger, http_session @@ -274,6 +275,10 @@ def fetch_taxonomy(url: str, fallback_path: str, offline=False) -> Optional[Taxo try: r = http_session.get(url, timeout=120) # might take some time + if r.status_code >= 300: + raise requests.HTTPError( + "Taxonomy download at %s returned status code {r.status_code}", url + ) data = r.json() except Exception as e: logger.exception(f"{type(e)} exception while fetching taxonomy at %s", url)