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 validation for absolute self link in item schema #1281

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

emmanuelmathot
Copy link
Collaborator

@emmanuelmathot emmanuelmathot commented May 14, 2024

Related Issue(s): #1241

Proposed Changes:

  1. Add validation for absolute self link in item schema

PR Checklist:

  • This PR is made against the dev branch (all proposed changes except releases should be against dev, not master).
  • This PR has no breaking changes.
  • I have added my changes to the CHANGELOG
    or a CHANGELOG entry is not required.
  • This PR affects the STAC API spec,
    and I have opened issue/PR #XXX to track the change.

"then": {
"properties": {
"href": {
"format": "iri"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about local (filesystem) catalogs? E.g. with a self link of /path/to/my/catalog.json?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be using the file protocol? file://path/to/my/...?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most tooling that I've seen won't do that, e.g. pystac.

Copy link
Collaborator

@m-mohr m-mohr May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say then pystac might be generating invalid STAC. The STAC Spec in 1.0 says explicitly "Absolute URL" and /path/to/my/catalog.json is not an absolute URL, it's just an absolute path.

Edit: There is a confusing "if it is available at a public URL" in the item spec, but that sounds like nonsense to me and is not present in the catalog and collection spec. A non absolute self link is useless. But yeah, if we need to cater for absolute paths, then we can pretty much close this PR because there's no reasonable way for us to validate, I think. Checking for a starting "/" won't work on Windows for example. But I think this PR is actually correct and might even remove the "if it is available at a public URL".

Copy link
Collaborator

@gadomski gadomski May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-mohr I chatted with some folks internally about this, and I think I'm more convinced to be 👎🏼 on requiring a valid URI for href. With the general vibe that STAC is meant to be flexible w/ recommendations for best practice, it was brought up that there might be systems that don't even use protocols, but just use opaque strings as keys to reference other entities. @philvarner put it like this:

... a link href can be any string, but usually it's a URL, locally it can be a file path, and less commonly some other opaque string

Copy link
Collaborator

@m-mohr m-mohr May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we need to fix the spec, whick pretty much always talks about URLs, not paths. It's always somewhat contrary to the core STAC princpiles document, which empraces HTTP as core. That might actually require a STAC 2.0 though, because some tooling may now expect URLs (e.g. STAC Browser). @gadomski Needs closer checks and discussion, I guess.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feelings in the community meeting:
Emmanuel, Francis, Mathias: +1 iri validation
Pete: -0.5 against iri validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify the self link is absolute
3 participants