Skip to content

Commit 254fb88

Browse files
committed
fix(shacl): 🐛 drop sub-threshold pyshacl violations at the source
Skip sh:ValidationResult nodes whose check severity is below the requested `requirement_severity` while iterating pyshacl results, so they never become Issues. This makes every consumer of `ValidationResult._issues` consistent with the threshold (not just `failed_requirements`/`failed_checks`) and avoids materializing non-actionable violations.
1 parent bb514b3 commit 254fb88

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • rocrate_validator/requirements/shacl

rocrate_validator/requirements/shacl/checks.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,18 @@ def __do_execute_check__(self, shacl_context: SHACLValidationContext):
282282
if requirementCheck is None:
283283
logger.warning("No check instance found for shape: %s", shape.key)
284284
continue
285+
# Drop violations whose check severity is below the requested
286+
# `requirement_severity`: pyshacl still emits sh:ValidationResult
287+
# nodes for sh:Warning / sh:Info, but they are not actionable at a
288+
# stricter validation level.
289+
if requirementCheck.severity < shacl_context.settings.requirement_severity:
290+
logger.debug(
291+
"Dropping violation for check %s: severity %s below requested %s",
292+
requirementCheck.identifier,
293+
requirementCheck.severity,
294+
shacl_context.settings.requirement_severity,
295+
)
296+
continue
285297
if (
286298
not shacl_context.settings.skip_checks
287299
or requirementCheck.identifier not in shacl_context.settings.skip_checks

0 commit comments

Comments
 (0)