diff --git a/swh/lister/phabricator/lister.py b/swh/lister/phabricator/lister.py --- a/swh/lister/phabricator/lister.py +++ b/swh/lister/phabricator/lister.py @@ -91,7 +91,7 @@ while True: params = self.get_request_params(after) logger.debug( - "Retrieving results on URI=%s, parameters %s", + "Retrieving results on URI %s with parameters %s", self.url, self.filter_params(params), ) @@ -99,12 +99,13 @@ if response.status_code != 200: logger.warning( - "Got unexpected status_code %s on %s: %s", + "Unexpected HTTP status code %s on %s: %s", response.status_code, response.url, response.content, ) - break + + response.raise_for_status() response_data = response.json() diff --git a/swh/lister/phabricator/tests/test_lister.py b/swh/lister/phabricator/tests/test_lister.py --- a/swh/lister/phabricator/tests/test_lister.py +++ b/swh/lister/phabricator/tests/test_lister.py @@ -7,6 +7,7 @@ from pathlib import Path import pytest +from requests.exceptions import HTTPError from swh.lister import USER_AGENT from swh.lister.phabricator.lister import PhabricatorLister, get_repo_url @@ -111,3 +112,24 @@ scheduler_origins = swh_scheduler.get_listed_origins(lister.lister_obj.id).origins assert len(scheduler_origins) == expected_nb_origins + + +def test_lister_request_error( + swh_scheduler, requests_mock, phabricator_repositories_page1, +): + FORGE_BASE_URL = "https://forge.softwareheritage.org" + + lister = PhabricatorLister( + scheduler=swh_scheduler, url=FORGE_BASE_URL, instance="swh", api_token="foo" + ) + + requests_mock.post( + f"{FORGE_BASE_URL}{lister.API_REPOSITORY_PATH}", + [ + {"status_code": 200, "json": phabricator_repositories_page1}, + {"status_code": 500, "reason": "Internal Server Error"}, + ], + ) + + with pytest.raises(HTTPError): + lister.run()