-
-
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.30% 82.31% +0.01%
==========================================
Files 72 72
Lines 7430 7446 +16
==========================================
+ Hits 6115 6129 +14
- Misses 1315 1317 +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/>...
|
99807e5
to
468fdb6
Compare
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!
|
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.