Skip to content

Make collection search more permissive #786

@gadomski

Description

@gadomski

Per Postel's law we should be ok reading invalid STAC collections. CSDA currently has invalid collections, and so searching throws an error:

$ stac-client collections https://csdap.earthdata.nasa.gov/stac/
'spatial'
Traceback (most recent call last):
  File "/Users/gadomski/Code/stac-utils/pystac-client/pystac_client/cli.py", line 432, in cli
    return collections(client, **args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gadomski/Code/stac-utils/pystac-client/pystac_client/cli.py", line 127, in collections
    collections_dicts = [c.to_dict() for c in result.collections()]
                                              ^^^^^^^^^^^^^^^^^^^^
  File "/Users/gadomski/Code/stac-utils/pystac-client/pystac_client/collection_search.py", line 375, in collections
    for collection in self.collections_as_dicts():
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gadomski/Code/stac-utils/pystac-client/pystac_client/collection_search.py", line 389, in collections_as_dicts
    for page in self.pages_as_dicts():
                ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gadomski/Code/stac-utils/pystac-client/pystac_client/collection_search.py", line 438, in pages_as_dicts
    for collection in filter(
                      ^^^^^^^
  File "/Users/gadomski/Code/stac-utils/pystac-client/pystac_client/collection_search.py", line 439, in <lambda>
    lambda x: collection_matches(x, **args),
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gadomski/Code/stac-utils/pystac-client/pystac_client/collection_search.py", line 64, in collection_matches
    collection_bboxes = collection_dict["extent"]["spatial"]["bbox"]
                        ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'spatial'

Metadata

Metadata

Assignees

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