stac-utils / stac-asset

Read and download STAC Assets, using a variety of authentication schemes
https://stac-asset.readthedocs.io
Apache License 2.0
39 stars 7 forks source link

Add more allowable ContentTypes or make validation optional? #223

Open scottyhq opened 4 days ago

scottyhq commented 4 days ago

https://github.com/stac-utils/stac-asset/blob/20a5d5ab8669867d3e5a7601072a501cde74e89d/src/stac_asset/validate.py#L3-L5

I was just this library out with a maxar item https://api.maxar.com/discovery/v1/catalogs/imagery/collections/wv01/items/102001008EC5AC00

But hit validation errors on the mime-types trying to download assets, which are almost the same. I don't think the asset type are standardized in STAC validation, but could be wrong! I thought about adding them to ALLOWABLE_PAIRS, but maybe just skipping this check altogether would be better?

DownloadError: ContentTypeError: the actual content type does not match the expected: actual=application/json, expected=application/geo+json
ContentTypeError: the actual content type does not match the expected: actual=application/json, expected=application/geo+json
ContentTypeError: the actual content type does not match the expected: actual=image/tiff, expected=image/tiff; application=geotiff
scottyhq commented 4 days ago

but maybe just skipping this check altogether would be better?

Ah, sorry after digging in the code a little bit I see that is already possible via config!

httpconfig = stac_asset.Config(http_headers={'MAXAR-API-KEY':os.environ['MAXAR_API_KEY']},
                                 http_check_content_type=False)
download_item(config=httpconfig)
gadomski commented 3 days ago

@scottyhq thanks for raising — since it's not uncommon for servers to have these media type mismatches, I wonder if switching to warn-by-default would be better UX?