Skip to content

Commit d27ac56

Browse files
authored
Merge pull request #3140 from bsipocz/BUG_irsa_most_error_parsing
BUG: fix `Most.query_object` error parsing
2 parents 3f4a051 + c95115f commit d27ac56

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ esa.jwst
4848

4949
- Add download_files_from_program method to get all products by program id [#3073]
5050

51+
ipac.irsa
52+
^^^^^^^^^
53+
54+
- Add more robust handling of errors returned in Most.query_object() responses.
55+
[#3140]
56+
5157
mpc
5258
^^^
5359

astroquery/ipac/irsa/most.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ def _parse_full_regular_response(self, response, withTarballs=False):
189189
html = BeautifulSoup(response.content, "html5lib")
190190
download_tags = html.find_all("a", string=re.compile(".*Download.*"))
191191

192+
# If for some reason this wasn't a full response with downloadable tags,
193+
# raise an explicit exception:
194+
if not download_tags:
195+
raise ValueError('Something has gone wrong, there are no results parsed. '
196+
f'For full response see: {response.text}')
192197
# this is "Download Results Table (above)"
193198
results_response = self._request("GET", download_tags[0]["href"])
194199
retdict["results"] = Table.read(results_response.text, format="ipac")
@@ -532,7 +537,7 @@ def query_object(self, catalog="wise_merge", input_mode="name_input", output_mod
532537

533538
# MOST will not raise an bad response if the query is bad because they
534539
# are not a REST API
535-
if "MOST: *** error:" in response.text:
540+
if "MOST: *** error:" in response.text or "most: error:" in response.text:
536541
raise InvalidQueryError(response.text)
537542

538543
# presume that response is HTML to simplify conditions

0 commit comments

Comments
 (0)