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

fix: Validate processing fields everywhere #6

Conversation

l0b0
Copy link
Contributor

@l0b0 l0b0 commented Nov 12, 2021

To reproduce the original issue:

  1. Change the value of .providers[0]['processing:software']['IPF-S2L1C'] to something not a string, such as 2.6.
  2. Run npm test.

The test passes even though the value should be considered invalid. I believe the reason for this is that anyOf requires that one of the sub-schemas are valid, not that one of the sub-schema structures are present. So even if some processing property values are invalid, as long as there is at least one valid value the JSON passes validation.

Caveat: Some unit tests would be in order to make sure the schema does the right thing in many more cases. If you're interested I can add some of those as well.

@l0b0 l0b0 marked this pull request as draft November 16, 2021 21:36
@l0b0 l0b0 force-pushed the fix/validate-processing-fields-everywhere branch 6 times, most recently from 05146ce to 9926ac3 Compare November 17, 2021 00:52
@m-mohr
Copy link
Contributor

m-mohr commented Nov 17, 2021

Hmm, interesting. Thanks for catching this. I'll investigate...

@m-mohr m-mohr self-requested a review November 17, 2021 09:01
@l0b0 l0b0 marked this pull request as ready for review November 17, 2021 21:00
@l0b0 l0b0 force-pushed the fix/validate-processing-fields-everywhere branch 2 times, most recently from cde1110 to 573cf70 Compare December 9, 2021 00:22
@l0b0
Copy link
Contributor Author

l0b0 commented Dec 9, 2021

Ping?

@l0b0
Copy link
Contributor Author

l0b0 commented Dec 9, 2021

Broken because of #14.

m-mohr added a commit that referenced this pull request Dec 11, 2021
@m-mohr
Copy link
Contributor

m-mohr commented Dec 11, 2021

Indeed, the anyOf is a problem. It's an issue in all extensions basically. If one of them is fullfilled, the others don't need to be fulfilled. You can fix this to some degree by making pure field validation with no field requirements in allOf and then add the requirements in anyOf. An example how I believe it can be solved: 8045be9
Nevertheless, this still does not solve the issue for the other potential occurances and only for provider.

PS: I'm basically the only one who's doing all the JSON Schema maintenance for the whole STAC spec + extension, which I have like 1-2 hours per month allocated for. Fixing this here and throughout the STAC ecosystem will need a funding effort ( @cholmes ) so that someone can work on this for some time...

@l0b0 l0b0 force-pushed the fix/validate-processing-fields-everywhere branch from 573cf70 to fb2c597 Compare December 13, 2021 02:27
@l0b0
Copy link
Contributor Author

l0b0 commented Dec 13, 2021

I've changed these to Jest.

@m-mohr
Copy link
Contributor

m-mohr commented Jan 3, 2022

I have updated the JSON Schema to properly validate fields and requirements in #18 so this might be obsolete

@l0b0 l0b0 force-pushed the fix/validate-processing-fields-everywhere branch from fb2c597 to c56bb2e Compare January 10, 2022 23:45
@l0b0
Copy link
Contributor Author

l0b0 commented Jan 11, 2022

I have updated the JSON Schema to properly validate fields and requirements in #18 so this might be obsolete

The "should fail validation without any summaries processing: properties" test fails with the schema in the main branch. Also, this adds tests which are easier to read and understand in isolation than the schema itself, making sure that future changes don't break anything.

@m-mohr
Copy link
Contributor

m-mohr commented Jan 11, 2022

The "should fail validation without any summaries processing: properties" test fails with the schema in the main branch.

Yes, but that is intended (if I understand the tests correctly) as there are still processing properties in providers. For Collections, it checks whether any place contains processing properties, so if any of summaries, assets, item_assets or providers have processing properties, the requirement for specifying at least one processing property is fulfilled. So the tests need to be fixed. See the note below the table for details: https://github.com/stac-extensions/processing#item-properties-and-collection-provider-fields

@l0b0
Copy link
Contributor Author

l0b0 commented Jan 11, 2022

It also fails "should fail validation with invalid providers processing:software value".

@l0b0
Copy link
Contributor Author

l0b0 commented Jan 11, 2022

The "should fail validation without any summaries processing: properties" test fails with the schema in the main branch.

Yes, but that is intended (if I understand the tests correctly) as there are still processing properties in providers.

I'll make sure it tests that.

@m-mohr
Copy link
Contributor

m-mohr commented Jan 11, 2022

It also fails "should fail validation with invalid providers processing:software value".

Haven't run your tests as I'm on my non-dev machine right now, but if I validate invalid stuff processing:software in providers in some online json schema validator it correctly throws an exception. So I guess something with your tests is wrong, maybe the expected error message has changed. Maybe it's worth checking the tests again. I've verified with around 25 different files and configurations that the schema works so I don't expect any major issues any more.

@l0b0 l0b0 force-pushed the fix/validate-processing-fields-everywhere branch from c56bb2e to 7d30fe1 Compare June 7, 2022 03:58
@l0b0
Copy link
Contributor Author

l0b0 commented Jun 7, 2022

Looks like you fixed the original issue, thank you! The tests should still be relevant.

@l0b0
Copy link
Contributor Author

l0b0 commented Feb 13, 2023

Anything missing to get this merged?

@m-mohr m-mohr removed their request for review February 13, 2023 22:31
@l0b0
Copy link
Contributor Author

l0b0 commented Sep 28, 2023

I don't work with STAC anymore, so I've unsubscribed from this. Please @ me if you would like some further feedback.

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 this pull request may close these issues.

3 participants