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

Add more allowable ContentTypes or make validation optional? #223

Closed
scottyhq opened this issue Oct 4, 2024 · 3 comments · Fixed by #227
Closed

Add more allowable ContentTypes or make validation optional? #223

scottyhq opened this issue Oct 4, 2024 · 3 comments · Fixed by #227

Comments

@scottyhq
Copy link

scottyhq commented Oct 4, 2024

ALLOWABLE_PAIRS = [
("image/tiff", "image/tiff; application=geotiff; profile=cloud-optimized"),
("text/xml", "application/xml"),

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
Copy link
Author

scottyhq commented Oct 4, 2024

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
Copy link
Member

gadomski commented Oct 4, 2024

@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?

@scottyhq
Copy link
Author

scottyhq commented Oct 8, 2024

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?

Sounds good to me!

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

Successfully merging a pull request may close this issue.

2 participants