feat: support cyclonedx 1.5 - ValidationResult management #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It looks like the changes in CycloneDX/cyclonedx-rust-cargo#639 to the validation error management introduced a hierarchy of errors through
ValidationErrorsKind
:ValidationErrorsKind::Struct
andValidationErrorsKind::List
refer to further inner (and hence nested)ValidationResult
ValidationErrorsKind::Field
,ValidationErrorsKind::Enum
andValidationErrorsKind::Custom
refer to the "final" validation error, i.e.ValidationError
Previously, in case of validation failure, i.e.
ValidationResult::Failed
, the failure's reasons were in a flatVec
structure containingFailureReason
that allowed us to easily run through them for implementing the workaround for CycloneDX/cyclonedx-rust-cargo#737This change in the validation errors management explains why the test
parse_cyclonedx_valid_14_newline
failed in PR-1721.In fact the
ValidationResult
that came out of validation is something like:In this PR I've added a recursive approach to traverse any
ValidationResult
in order to collect all of the distinct error messages.With this fix, the tests are fine with no changes (also the
parse_cyclonedx_invalid_serial_number
one that failed on PR-1721 as well):