Fix inherited extension slices incorrectly appearing in child differential#1609
Conversation
…ntial When a child profile inherits from a parent that defines an extension slice and the child adds its own slicing on a parent element, the inherited extension slice was incorrectly appearing in the child's differential. Root cause: In cloneChildren(), when recaptureSliceExtensions=false, extension slices retain their _original via e.clone(false), but the cloned element's id is updated to include the new slice prefix. Since id is compared in hasDiff(), this mismatch caused inherited extension slices to appear in the differential even though nothing changed. Fix: Update _original.id to match the cloned element's new id when not recapturing, so the id comparison doesn't produce false positives.
|
Thank you for this contribution, @glichtner. I apologize for the time it has taken me to review it. I've run this against the 100 most recently updated FSH projects and confirmed it works as expected. There are changes in output compared to the latest release, but those changes make sense in light of this PR and do not negatively impact those projects. So that's good! We prefer to have changes accompanied by unit tests demonstrating the change. I appreciate the simple test case you put in the description. Might you be able to add a similar unit test? I'd suggest add a test similar to this test (or updating that test if that makes more sense). If you need any help, let me know. Thanks again! |
cmoesel
left a comment
There was a problem hiding this comment.
Thanks for adding the test! I confirmed that the test fails without your fix and succeeds with your fix. Perfect!
Thanks again for your contribution!
|
Happy to help. Thank you for your work on sushi! |
Problem
When a child profile inherits from a parent that defines an extension slice (e.g., on
content.component.extensionin the example below), and the child adds its own slicing on a parent element (e.g.,contentwith anoutcomeslice), the inherited extension slice incorrectly appears in the child's differential under the new slice path (which later leads to validation errors in the IG Publisher).How to reproduce
Minimal reproduction case: https://github.com/glichtner/fsh-extension-slice-repro
Expected
The
Childprofile's differential should only contain elements that were actually constrained:Actual
The differential incorrectly contains the inherited extension slice:
Cause
In
cloneChildren(), whenrecaptureSliceExtensions=false, extension slices retain their original_originalviae.clone(false), but the cloned element'sidis updated to include the new slice prefix. Sinceidis compared inhasDiff(), this mismatch causes the inherited extension slice to appear in the differential even though nothing actually changed.Suggested fix
Update
_original.idto match the cloned element's newidwhen not recapturing, so the id comparison doesn't produce false positives inhasDiff().