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

lists in result messages #129

Merged
merged 5 commits into from
May 7, 2024
Merged

lists in result messages #129

merged 5 commits into from
May 7, 2024

Conversation

giacomociti
Copy link
Contributor

should address #109 . Result messages include the first (three) elements of lists

Copy link

changeset-bot bot commented Apr 12, 2024

🦋 Changeset detected

Latest commit: f732f93

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
rdf-validate-shacl Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 346 to 347
const items = Array.from(take(3, list))
return items.join(', ') + (items.length === 3 ? ' ...' : '')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it would be useful to give even more info than just an ellipsis. If it does not affect performance too much

Suggested change
const items = Array.from(take(3, list))
return items.join(', ') + (items.length === 3 ? ' ...' : '')
const { head, count } = take(3, list)
const items = Array.from(head)
return items.join(', ') + (items.length === 3 ? ` (and ${count} more)` : '')


assert.strictEqual(report.results.length, 1)
assert.strictEqual(report.results[0].message.length, 1)
assert.strictEqual(report.results[0].message[0].value, 'Value is not one of the allowed values: a, b, c ...')
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does the message look like when items are IRIs?

@giacomociti
Copy link
Contributor Author

added a commit to also address #131 because the information in the rdfs:comment and in sh:resultMessage is complementary

@Rdataflow
Copy link

@giacomociti FYI this PR may have a regression which occurs for some cubes while not for others - can you reproduce?

repro:

npx barnard59 cube fetch-metadata --endpoint https://ld.admin.ch/query --cube https://environment.ld.admin.ch/foen/ubd0066/12 | npx barnard59 cube check-metadata --profile ./validation/profile-visualize.ttl

msg:

TypeError: Cannot read properties of undefined (reading 'size')
at inListSize (file:///tmp/test/node_modules/rdf-validate-shacl/src/dataset-utils.js:43:33)
at extractSourceShapeStructure (file:///tmp/test/node_modules/rdf-validate-shacl/src/dataset-utils.js:48:41)
at extractSourceShapeStructure.next (<anonymous>)
at ValidationEngine.copySourceShapeStructure (file:///tmp/test/node_modules/rdf-validate-shacl/src/validation-engine.js:271:16)
at ValidationEngine.createResult (file:///tmp/test/node_modules/rdf-validate-shacl/src/validation-engine.js:244:10)
at ValidationEngine.createResultFromObject (file:///tmp/test/node_modules/rdf-validate-shacl/src/validation-engine.js:181:25)
at file:///tmp/test/node_modules/rdf-validate-shacl/src/validation-engine.js:131:37
at Array.map (<anonymous>)
at ValidationEngine.validateValueNodeAgainstConstraint (file:///tmp/test/node_modules/rdf-validate-shacl/src/validation-engine.js:131:8)
at ValidationEngine.validateNodeAgainstConstraint (file:///tmp/test/node_modules/rdf-validate-shacl/src/validation-engine.js:119:19)

nb: some more repro cases

npx barnard59 cube fetch-metadata --endpoint https://ld.admin.ch/query --cube https://environment.ld.admin.ch/foen/EFV_cofog_international/2 | npx barnard59 cube check-metadata --profile ./validation/profile-visualize.ttl
npx barnard59 cube fetch-metadata --endpoint https://ld.admin.ch/query --cube https://environment.ld.admin.ch/foen/nfi/nfi_C-1029/cube/2023-3 | npx barnard59 cube check-metadata --profile ./validation/profile-visualize.ttl
npx barnard59 cube fetch-metadata --endpoint https://int.ld.admin.ch/query --cube https://agriculture.ld.admin.ch/foag/cube/Eggs/Consumption_Price_Month | npx barnard59 cube check-metadata --profile ./validation/profile-visualize.ttl
npx barnard59 cube fetch-metadata --endpoint https://int.ld.admin.ch/query --cube https://health.ld.admin.ch/fsvo/gefahrFRESIL/7 | npx barnard59 cube check-metadata --profile ./validation/profile-visualize.ttl
...

@giacomociti
Copy link
Contributor Author

Nice catch @Rdataflow : the list of values allowed by sh:in is collected lazily; in your case, it was needed in the report shape but not initialized yet because not needed during validation.

I managed to fix the issue, also introducing a non-regression test. But I'm not super-happy with the design: the list initialization is now within the Constraint class, but it is a feature specific for the sh:in constraint. Maybe @tpluscode can suggest an improvement

@Rdataflow
Copy link

@giacomociti thanks for your fix - confirm it works here 👍

@tpluscode
Copy link
Collaborator

Maybe @tpluscode can suggest an improvement

Not without diving deeper. I suggest we create a ticket to improve in the future and roll with what we have now

@giacomociti giacomociti merged commit e01b85c into master May 7, 2024
3 checks passed
@giacomociti giacomociti deleted the list-in-message branch May 7, 2024 10:51
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.

None yet

3 participants