Skip to content

retrieving non-STAC entities via Links throws unintended error #340

@philvarner

Description

@philvarner

This code attempts to retrieve the root service-desc link as required by OAFeat. This file is OpenAPI rather than STAC.

catalog: Client = Client.open("https://earth-search.aws.element84.com/v0")
print(list(catalog.get_stac_objects('service-desc')))

Expected:

I would expect to get from this some type of error response that it's not a STAC object -- empty genexp, None, or a documented exception.

Actual:

The attempted read of the non-existant 'links' key in the object dict returns a KeyError.

  File "/Users/philvarner/.local/share/virtualenvs/stac-api-validation-suite-tzI1nfla/lib/python3.9/site-packages/pystac/stac_object.py", line 343, in get_stac_objects
    link.resolve_stac_object(root=self.get_root())
  File "/Users/philvarner/.local/share/virtualenvs/stac-api-validation-suite-tzI1nfla/lib/python3.9/site-packages/pystac/link.py", line 146, in resolve_stac_object
    obj = STAC_IO.read_stac_object(target_href, root=root)
  File "/Users/philvarner/.local/share/virtualenvs/stac-api-validation-suite-tzI1nfla/lib/python3.9/site-packages/pystac/stac_io.py", line 131, in read_stac_object
    return cls.stac_object_from_dict(d, href=uri, root=root)
  File "/Users/philvarner/.local/share/virtualenvs/stac-api-validation-suite-tzI1nfla/lib/python3.9/site-packages/pystac/serialization/__init__.py", line 37, in stac_object_from_dict
    return Catalog.from_dict(d, href=href, root=root)
  File "/Users/philvarner/.local/share/virtualenvs/stac-api-validation-suite-tzI1nfla/lib/python3.9/site-packages/pystac/catalog.py", line 786, in from_dict
    catalog_type = CatalogType.determine_type(d)
  File "/Users/philvarner/.local/share/virtualenvs/stac-api-validation-suite-tzI1nfla/lib/python3.9/site-packages/pystac/catalog.py", line 60, in determine_type
    for link in stac_json['links']:
KeyError: 'links'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThings which are broken

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions