-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
More information in error message when _get_endpoint requests fail #641
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #641 +/- ##
==========================================
+ Coverage 82.40% 82.47% +0.07%
==========================================
Files 72 72
Lines 7438 7480 +42
==========================================
+ Hits 6129 6169 +40
- Misses 1309 1311 +2 ☔ View full report in Codecov by Sentry. |
d8b8983
to
d5f5e41
Compare
Thanks for the PR. I have the feeling that we may have one or a couple of issues open about this, if you're up for finding them please link them in the OP comment. |
The only related issues I found were: Although the issue description in both is a bit different then the specific change this PR is attempting to address. |
883598e
to
bef7764
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0285fd5
to
0e0051c
Compare
Thanks! Test failures are unrelated upstream issues that are expected to go away once upstream deployment is done. |
On Fri, Jan 24, 2025 at 10:33:20AM -0800, stvoutsin wrote:
@stvoutsin commented on this pull request.
> @@ -32,17 +32,43 @@ def _get_endpoint_candidates(self, endpoint):
return [f'{curated_baseurl}/{endpoint}', url_sibling(curated_baseurl, endpoint)]
def _get_endpoint(self, endpoint):
- for ep_url in self._get_endpoint_candidates(endpoint):
+ """Attempt to connect to service endpoint"""
+ attempted_urls = []
+
+ try:
+ candidates = self._get_endpoint_candidates(endpoint)
+ except Exception as e:
I've added the exceptions I'd expect to be thrown here (`ValueError`, `TypeError` & `AttributeError`). Let me know if you think I've missed any
AttributeError would catch the case when someone passes a non-String.
Personally, I probably would not bother catching and explaining
these, but since these days the original traceback is preserved,
that's not dramatic, and so that's fine for me, and I can see when
the explanation given is actually helpful.
I've tried to elicit a ValueError or a TypeError from urlparse which,
I think, is the main source of exceptions here but failed. Hence,
based on my philosophy that it's usually wise to let "unusual"
exceptions propagate to the user I'd rather not catch them. The
logic is somewhat like "If you don't know why you would see an
exception here, don't try to explain it; a bad error message is
better than a wrong one.", which perhaps is a corollary to then Zen
of Python's "In the face of ambiguity, refuse the temptation to
guess."
Other than that, I think all of this is an improvement, so let's go.
And let's, at the IVOA level, try to get rid of the horrible
_get_endpoint_candidates in the first place. I'm still trying to get
traction for <http://ivoa.net/documents/caproles/>...
|
8339b14
to
abee48e
Compare
Thanks for the comments!
If we just let this, as well as the In the most recent commit, I've slightly modified by removing the Approach 1 (Propagate Errors)AttributeError:
Value Error
Approach 2 (Explicit handling of Errors):
AttributeError:
Value Error
Interested to hear your thoughts on this, I think either case is fine really because both are really obscure and rare cases that users should rarely encounter. I'll read up on the caproles doc, but I agree the need for that |
On Mon, Jan 27, 2025 at 04:08:24PM -0800, stvoutsin wrote:
Interested to hear your thoughts on this, I think either case is
fine really because both are really obscure and rare cases that
users should rarely encounter.
I had missed the ValueError for IPv6, and I agree it's better UX if we
catch these two. Thanks!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great improvement. I don't know how far we want to go but for the uninitiated users we could provide more details:
ConnectionError
is raised when the service cannot be reached: wrong URL, DNS or other networking problem, server down (?)- HTTP 5** errors are generally server errors that the user cannot do much about. The response bodies could provide more details. I think somewhere else in the code we attached the response body to the exception if it's in text format but I forgot where exactly. But users could be directed to check the message body with a browser. Also 503 might have a Retry-After header that can useful info. The code might be returned when service is in maintenance.
- HTTP 4** in general have something to do with the request so user might be able to act on although in this case is such a simple request that most of error codes can be considered server errors.
These are just suggestions
1f3ba2f
to
af833aa
Compare
e06c76a
to
999356d
Compare
999356d
to
b2517a9
Compare
140626a
to
b49f288
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something has went wrong with the rebase/squashing and now this contains unrelated changes.
7f28769
to
1915228
Compare
My bad, I forgot I was working off a fork so I messed up the rebase. Should be good now, however I think I may have to add some more test cases since there are some additional changes based on suggestions from @andamian |
Thanks for the feedback! I've taken your suggestions and modified the error handling a bit, to provide more context based on the various errors we may encounter, i.e. check for retry-after for 503s and provide a more meaningful message for ConnectionError. Let me know if the changes look reasonable or if I've missed anything and I'll be happy to adjust it. |
Added some more test cases for TAP error handling
1805f66
to
6b67d19
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more user friendly especially with less experience users. Thank you for your contribution @stvoutsin.
Summary
Currently when a user provides an invalid TAP URL or encounters connection issues during instantiation:
tap_service = pyvo.dal.TAPService(baseurl)
the error message is:DALServiceError: No working capabilities endpoint provided
We've found that this is slightly confusing for our users and lacks a bit of information on what went wrong.
Changes
This PR:
Other Changes
__all__
in dal.queryExample
Example improved error message:
Related Issues
#125
#586
Interested to hear if these changes make sense or if you have any objections / alternative approaches you'd rather go with.