Closed Mahir-Sparkess closed 3 years ago
Hello again, I have found the cause of my TypeError. In my STAC collection, we have 'providers' and 'summaries' stated even if they are a None value:
'summaries': {'mip_era': ['CMIP6'], 'activity_id': ['AerChemMIP'], 'source_id': ['CNRM-ESM2-1'], 'table_id': ['Amon', 'Lmon', 'Omon'], 'institution_id': ['CNRM-CERFACS']},
'providers': Null
Due to our STAC implementation explicitly states 'proivders' even if we have None, it passes the if statement for the Collection class. Which is then passing a None value into the list comprehension that is causing my error.
So instead in my branch, I've changed the if statement from:
https://github.com/brazil-data-cube/stac.py/blob/b52ed35aee07dad0c4e4588722b7234cb28b44b4/stac/collection.py#L112-L113
Replacing the in
to a get
which also fixes my issue:
https://github.com/cedadev/stac.py/blob/2ddaae900c0968e192c7173c3152b699afc04ed7/stac/collection.py#L111-L112
I've also updated my PR #105 so that it's no longer using a try/except statement anymore. I hope this is acceptable :)
When running the
service.catalog
method, it would raise a TypeError, the console log shows this:I am unsure why I would get a TypeError since my providers' are null in the JSON, so it should skip the statement and return an empty list, same with my summaries. My solution: if it crashes at a TypeError, then catch the error and return the empty dict or list, as if to skip the statement.