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

HTTP prefix require sometimes in HyP3 URL #272

Open
jhkennedy opened this issue Apr 26, 2024 · 0 comments
Open

HTTP prefix require sometimes in HyP3 URL #272

jhkennedy opened this issue Apr 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jhkennedy
Copy link
Contributor

I recently noticed that I can connect and auth to a HyP3 deployment even if I don't provide https:// as part of the API URL:

>>> import hyp3_sdk as sdk
>>> hyp3 = sdk.HyP3('hyp3-api.asf.alaska.edu')

but if I try and interact with HyP3 at all, I get a requests exception:

>>> hyp3.my_info()
Traceback (most recent call last):
  File "/home/jhkennedy/mambaforge/envs/RAiDER/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3548, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-4c1162596b76>", line 1, in <module>
    hyp3.my_info()
  File "/home/jhkennedy/mambaforge/envs/RAiDER/lib/python3.12/site-packages/hyp3_sdk/hyp3.py", line 487, in my_info
    response = self.session.get(urljoin(self.url, '/user'))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jhkennedy/mambaforge/envs/RAiDER/lib/python3.12/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jhkennedy/mambaforge/envs/RAiDER/lib/python3.12/site-packages/requests/sessions.py", line 575, in request
    prep = self.prepare_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jhkennedy/mambaforge/envs/RAiDER/lib/python3.12/site-packages/requests/sessions.py", line 486, in prepare_request
    p.prepare(
  File "/home/jhkennedy/mambaforge/envs/RAiDER/lib/python3.12/site-packages/requests/models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "/home/jhkennedy/mambaforge/envs/RAiDER/lib/python3.12/site-packages/requests/models.py", line 439, in prepare_url
    raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL '/user': No scheme supplied. Perhaps you meant https:///user?

I think we should handle this better either by adding the https:// ourselves or rejecting URLs that don't have it when we instantiate the HyP3 class.

@jhkennedy jhkennedy added the bug Something isn't working label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant