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

Browseable validation throws KeyError exception #527

Open
LeoBreebaart opened this issue Sep 9, 2024 · 1 comment
Open

Browseable validation throws KeyError exception #527

LeoBreebaart opened this issue Sep 9, 2024 · 1 comment
Assignees

Comments

@LeoBreebaart
Copy link

I get the following exception trace when trying to run the validator (v0.6.2) with --conformance browseable:

INFO:stac_api_validator.validations:Validating STAC API - Browseable conformance class.
Failed.
Error http://127.0.0.1:8000/api/zipped: <class 'AttributeError'> 'Item' object has no attribute 'collection' Traceback (most recent call last):
  File "/Users/leo/.pyenv/versions/test/lib/python3.10/site-packages/stac_api_validator/__main__.py", line 163, in main
    (warnings, errors) = validate_api(
  File "/Users/leo/.pyenv/versions/test/lib/python3.10/site-packages/stac_api_validator/validations.py", line 579, in validate_api
    validate_browseable(landing_page_body, errors, warnings, r_session)
  File "/Users/leo/.pyenv/versions/test/lib/python3.10/site-packages/stac_api_validator/validations.py", line 849, in validate_browseable
    params={"ids": item.id, "collections": item.collection},
AttributeError: 'Item' object has no attribute 'collection'

The item in Line 849 of validations.py is the result from a call to pystac's (v1.10.1) Catalog.from_dict(root_body).get_all_items(). However:

  1. get_all_items() is now deprecated according to https://pystac.readthedocs.io/en/stable/_modules/pystac/catalog.html#Catalog.get_all_items
  2. I can verify separately that items returned from that call indeed do not contain a collection field, just a collection_id field.

If I patch line 849 to use collection_id my API validates perfectly fine.

Is this indeed an issue in the validator, or am I missing something?

Regards,

-- Leo

@gadomski
Copy link
Member

@LeoBreebaart thanks for the report -- I think this is actually a bug in pystac, and have opened up a fix here: stac-utils/pystac#1400. Once that's merged and released, we'll update that dependency on this repo.

In the meantime, if you wanted to patch your environment to (hopefully) work now, you could:

pip install git+https://github.com/stac-utils/pystac@no-collection

@gadomski gadomski self-assigned this Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants