Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DalResults does not appropriately handle 404 (or any HTTP error) #625

Open
mtauraso opened this issue Nov 26, 2024 · 3 comments
Open

DalResults does not appropriately handle 404 (or any HTTP error) #625

mtauraso opened this issue Nov 26, 2024 · 3 comments

Comments

@mtauraso
Copy link

mtauraso commented Nov 26, 2024

Any calls to DalResult.from_result_url resulting in an error condition (404, 5xx etc) will proceed to trying to parse the response as a votable.

For a user calling a higher-level function like DataLinkResults.from_result_url the resulting error is a parse error deep inside votable and distracts from the actual problem (the service doesn't have what they're looking for).

I've filed an example of this behavior occurring at an LSST data facility here. That bug has an example notebook which is a cut-down version of an LSST tutorial showcasing the bug in action.

The pyvo issue is here. Either from_result_url or _from_result_url should check .status on the HTTPResponse object returned from session.get and raise an appropriate exception.

I'm happy to submit a PR if there is support for the fix suggested above.

@mtauraso mtauraso changed the title DalResults does not handle 404 (or any error) sanely DalResults does not appropriately handle 404 (or any HTTP error) Nov 26, 2024
@msdemlei
Copy link
Contributor

msdemlei commented Nov 27, 2024 via email

@mtauraso
Copy link
Author

mtauraso commented Dec 2, 2024

That would be great. I'd say the behaviour should be: * For content-types application/x-votable+xml (I think we don't need to parse the media type, as it's unlikely we'll have parameters here) and text/xml, try to parse as a VOTable. If there is a DALI-type (or SCS-type) error message in there, take its text and make a DAL error out of it. * If VOTable parsing fails or for other content types, fall back to whatever exception requests produces. Rationale: The publisher-produced message in a DALI-compliant VOTable is almost certain to be more informative than anything we could reasonably come up with ourselves. But if that fails, it's probably better to rely on the large user base of requests that will hopefully come up with useful diagnostics.

This sounds excellent. I'm happy to start on this.

I clicked around quickly to see if there were any contribution instructions I should be sure I'm following. I didn't find anything beyond the Astropy CoC. Is there anything in particular I should be aware of when submitting a PR besides keeping CI clean?

@bsipocz
Copy link
Member

bsipocz commented Dec 2, 2024

Yes, pyvo specific dev docs are coming. Until then the jist is: Keeping the commit history clean would be appreciated, and rebased when/if you need to refresh the base branch rather than github resolve and add a merge commits. Also, please refrain from running auto reformatting anything or add changes unrelated to the particular fix, if you run into any other bugs or stuff it's preferred to fix them in a separate PR.

And we have two types of tests, locally mocked ones, but also some functionality has tests that reaches out to the remote servers. You can run the latter lot by using the -R pytest option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants