fix: FilterMappingQualifier for a list with CollectionMappingQualifier failing - #46
Open
artacho-xitaso wants to merge 3 commits into
Open
fix: FilterMappingQualifier for a list with CollectionMappingQualifier failing#46artacho-xitaso wants to merge 3 commits into
artacho-xitaso wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Submodel data-to-instance mapping pipeline to prevent generation failures when an optional wrapper element is gated by a filter but contains a mandatory (OneToMany) collection mapping that would otherwise throw on empty payloads.
Changes:
- Run
FilterElementsboth before and afterDuplicateCollectionsto allow structural pruning prior to duplication. - Add logic to skip evaluating filter expressions containing
[*](wildcard) inFilterElementsStep. - Add fixture-based tests covering: optional wrapper omitted, optional wrapper kept, and wildcard filter expression skipped; update architecture documentation.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wiki/Rules-Engine-Architecture.md | Updates documented pipeline step ordering/count and explains the added filter pass. |
| MnestixCore/AASGenerator/SubmodelDataToInstanceMapper/Steps/FilterElementsStep.cs | Skips evaluation of wildcard ([*]) filter expressions. |
| MnestixCore/AASGenerator/SubmodelDataToInstanceMapper/DataMapper.cs | Inserts a pre-duplication FilterElements step. |
| Core.Tests/AasGenerator/AasGeneratorTests.cs | Adds three regression tests for the new pipeline behavior. |
| Core.Tests/AasGenerator/TestJsons/InputFilterWildcardExpressionSkipped/TemplateSubmodel.json | New fixture: template with wildcard filter expression. |
| Core.Tests/AasGenerator/TestJsons/InputFilterWildcardExpressionSkipped/Data.json | New fixture: data payload for wildcard filter case. |
| Core.Tests/AasGenerator/TestJsons/InputFilterWildcardExpressionSkipped/ExpectedResult.json | New fixture: expected output for wildcard filter case. |
| Core.Tests/AasGenerator/TestJsons/InputFilterOmitsOptionalCollection/TemplateSubmodel.json | New fixture: optional wrapper + mandatory inner collection gated by filter. |
| Core.Tests/AasGenerator/TestJsons/InputFilterOmitsOptionalCollection/Data.json | New fixture: empty payload for the gated collection. |
| Core.Tests/AasGenerator/TestJsons/InputFilterOmitsOptionalCollection/ExpectedResult.json | New fixture: expected output omitting the optional wrapper. |
| Core.Tests/AasGenerator/TestJsons/InputFilterKeepsOptionalCollection/TemplateSubmodel.json | New fixture: same blueprint as omit-case. |
| Core.Tests/AasGenerator/TestJsons/InputFilterKeepsOptionalCollection/Data.json | New fixture: payload containing items so filter passes. |
| Core.Tests/AasGenerator/TestJsons/InputFilterKeepsOptionalCollection/ExpectedResult.json | New fixture: expected output keeping and duplicating the collection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
MR: FilterMappingQualifier for a list with CollectionMappingQualifier failing
Branch:
fix/filter-mapping-before-collection-mapping→devSummary
A blueprint where an optional (
ZeroToOne)SubmodelElementListwraps a mandatory (OneToMany)CollectionMappingInfocollection and gates the list with a
FilterMappingInfo(e.g.$count(marking) > 0) threw during generation when the payloadhad no items, instead of omitting the list. Root cause:
DuplicateCollectionsran beforeFilterElementsand threw on themandatory-but-empty inner collection before the filter could drop its optional parent. This MR runs
FilterElementsbeforeand after
DuplicateCollectionsso structural filters prune the branch first.Changes
MnestixCore/AASGenerator/SubmodelDataToInstanceMapper/DataMapper.csFilterElementsstep beforeDuplicateCollectionsin the pipeline (now: Filter → Duplicate → Filter).Pre-pass handles structural filters so an optional wrapper is dropped before duplication can throw on empty data; post-pass
keeps handling per-item filters.
MnestixCore/AASGenerator/SubmodelDataToInstanceMapper/Steps/FilterElementsStep.cs[*]. A per-item filter cannot be evaluated as a single boolean before the collectionis duplicated/indexed, so evaluating it pre-duplication would resolve the whole array and give a meaningless verdict.
Skipping makes the same step safe to run in both pipeline positions (self-routes on
[*]).wiki/Rules-Engine-Architecture.mdFilterElements (pre-duplication)at step 4,DuplicateCollectionsat 5,FilterElements (post-duplication)at 6; renumbered the rest. Documented the reason for the pre-pass and the[*]-skip,incl. the note that
[*]→[i]rewrite for filter qualifiers is not yet implemented (per-item filters currently alwaysskipped).