Skip to content

HTTP prefix require sometimes in HyP3 URL #272

Description

@jhkennedy

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions