From ac4a629a1ed4c869568b8f6708031e690141c9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Thu, 28 Nov 2024 03:33:31 -0800 Subject: [PATCH 1/3] BUG: add handling case when no results returned but a new error message --- astroquery/ipac/irsa/most.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/astroquery/ipac/irsa/most.py b/astroquery/ipac/irsa/most.py index d46afb1940..874dc7e8c6 100644 --- a/astroquery/ipac/irsa/most.py +++ b/astroquery/ipac/irsa/most.py @@ -189,6 +189,11 @@ def _parse_full_regular_response(self, response, withTarballs=False): html = BeautifulSoup(response.content, "html5lib") download_tags = html.find_all("a", string=re.compile(".*Download.*")) + # If for some reason this wasn't a full response with downloadable tags, + # raise an explicit exception: + if not download_tags: + raise ValueError('Something has gone wrong, there are no results parsed. ' + f'For full response see: {response.text}') # this is "Download Results Table (above)" results_response = self._request("GET", download_tags[0]["href"]) retdict["results"] = Table.read(results_response.text, format="ipac") From f11f73bff0401bb7b895d86b0f1b59796a02edf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Thu, 28 Nov 2024 03:34:21 -0800 Subject: [PATCH 2/3] BUG: adding new error string matching --- astroquery/ipac/irsa/most.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astroquery/ipac/irsa/most.py b/astroquery/ipac/irsa/most.py index 874dc7e8c6..ef136a10e7 100644 --- a/astroquery/ipac/irsa/most.py +++ b/astroquery/ipac/irsa/most.py @@ -537,7 +537,7 @@ def query_object(self, catalog="wise_merge", input_mode="name_input", output_mod # MOST will not raise an bad response if the query is bad because they # are not a REST API - if "MOST: *** error:" in response.text: + if "MOST: *** error:" in response.text or "most: error:" in response.text: raise InvalidQueryError(response.text) # presume that response is HTML to simplify conditions From c95115fe67715c2b27205f4bd8bf2d874bafd5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Thu, 28 Nov 2024 03:39:17 -0800 Subject: [PATCH 3/3] DOC: adding changelog --- CHANGES.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 15c4c47eb5..46761a7ced 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -48,6 +48,12 @@ esa.jwst - Add download_files_from_program method to get all products by program id [#3073] +ipac.irsa +^^^^^^^^^ + +- Add more robust handling of errors returned in Most.query_object() responses. + [#3140] + mpc ^^^