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

DPP Schema 0.5.1 proposal fixing constant value requirements #197

Draft
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

absoludity
Copy link
Contributor

@absoludity absoludity commented Jan 14, 2025

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation Update
  • 🎨 Style
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • πŸ“¦ Chore (Release)
  • ⏩ Revert

Description

Running our 0.5.0 DPP schema validation for the example Digital Product Passport for FoodAgility fails with:

Testing Credential: digitalProductPassport
Version: v0.5.0
Path: credentials/productPassport/DigitalLivestockPassport-decoded-invalid.json
Result: FAIL
Error: 
/type field must be equal to constant.
/type/0 field must be equal to one of the allowed values. Allowed values: DigitalProductPassport, VerifiableCredential.
/@context field must be equal to constant.
/@context/1 field must be equal to one of the allowed values. Allowed values: https://www.w3.org/ns/credentials/v2, https://test.uncefact.org/vocabulary/untp/dpp/0.5.0/.
/credentialSubject/type field must be equal to constant.
/credentialSubject/type/0 field must be equal to one of the allowed values. Allowed values: Product.

This (draft) PR defines a proposed schema change (for 0.5.1) that require the arrays to contain at least one (or two) specific values, rather than being constant. If there's agreement, we'll request this change in jargon (or better, wait for any other schema changes for the next release, before requesting the change in jargon).

I've included the decoded original example DPP from FoodAgility (decoded-invalid) as well as a slightly modified version (decoded-valid) so that they can both be tested with yarn run untp test. The updated version (decode-valid) ensures that

  • the "type" includes "DigitalProductPassport" (in addition to "DigitalLivestockPassport"),
  • the "context" field includes the standard dpp context.

Note: the example DPP includes a context, aatp-dlp-context which appears to define the standard dpp context as well. It should be defining only the additional context for the DigitalLivestockPassport, I assume - I'll investigate that next. In the mean-time, it will be interesting to see if it fails the jsonld validation which @ashleythedeveloper is adding, or whether it will pass because it doesn't change or redefine those context values.

Note 2: The standard JSON-schema error messages used by the lib being used here, for the "contains", is not great. If, for example, the DPP's "type" field doesn't include the "DigitalProductPassport" value, the error is:

Result: FAIL
Error: 
/type/0 field must be equal to constant.
/type/1 field must be equal to constant.
/type field must contain at least 1 valid item(s).

which is incorrect (the items in the array aren't const, rather one of them needs to contain the value "DigitalProductPassport" and none do). I'll investigate if this is the lib that we're using or whether it can be improved.

Added tests?

  • πŸ‘ yes (well, added test data for a proposed schema change, not code tests)
  • πŸ™… no, because they aren't needed
  • πŸ™‹ no, because I need help

Added to documentation?

  • πŸ“– Mock App docs site
  • πŸ“œ README.md
  • πŸ“• storybook
  • πŸ™… no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

Ref: https://github.com/gs-gs/fa-ag-trace/issues/905

Also adds a valid and invalid livestock example.
@absoludity
Copy link
Contributor Author

The actual diff for the 0.5.0 to 0.5.1 change is in commit 64cefdd

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.

1 participant