-
Couldn't load subscription status.
- Fork 30
Remove restriction on valid media types for links #182
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
Merged
vincentsarago
merged 4 commits into
stac-utils:main
from
mishaschwartz:unrestrict-media-types
Jun 18, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this test is inappropriate, or at least should not "encourage" it with explicitly validating erroneous values.
Ideally,
hrefshould have a protocol, specificallyfile://if local files makes any sense here.Though, that has other implications in STAC (eg: stac-utils/pystac#1347), so I would let them decide about this.
Media-type should at least validate that
[\w-]+/[\w-.]+.*are handled as bare minimum (ie: RFC6838 section 4.2).It could be more strict to consider only valid RFC2046 types if desired, and could define the specific
;and parameters regexes if really invested in validating the specific pattern, but they have to minimally be permitted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's anything technically "erroneous" about
some random string... while the provided RFC6838 link provides a syntax requirement for "registered media types", we're explicitly allowing non-registered media types in this library, so the syntax requirement doesn't apply.I'd be ok w/ warning if the media type doesn't fit some sort of expectation (either in our list, or that regex, or whatever), but I think an error is too strong.
W.r.t. the href, there's a lot of "absolute file system" hrefs in the wild, so I'm ok with including it here. If we wanted to be "correct" we could update it to
./hello/world.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't
application/x-[something]orapplication/vdn.[something]be required for unregistered types? Won't most libraries break if there is not at least a<type>/<subtype>split?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe? I guess I'm just curious what we're trying to gain by validating others' media types. I generally favor "permissive reads, strict writes" for STAC tooling
For this library, I think that means warning on "surprising" (not erroring) media types and providing string constants for "correct" ones (which we do).
Regarding the split question, I've seen a lot of libraries do direct string matching (not splitting) , which means subtypes or profiles (like
cloud-optimized) break matching anyways.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine if that's the decision. My understanding was that it was the opposite with strict validation given that the (too)specific set of
MediaTypesenum was used instead ofstrfrom the start. As mentioned, I think the bare minimum would be[\w-]+/[\w-.]+.*that would allow most flexibility while at least avoiding basic mistakes of malformed media-types. Note that the pattern includes.*specifically to allow theprofile=cloud-optimizedor other similar parameters.