Skip to content

Fix building mappings in snapshot mode when parent has no mappings - #1618

Merged
jduteau merged 2 commits into
masterfrom
fix-snapshot-error
Apr 15, 2026
Merged

Fix building mappings in snapshot mode when parent has no mappings#1618
jduteau merged 2 commits into
masterfrom
fix-snapshot-error

Conversation

@cmoesel

@cmoesel cmoesel commented Mar 28, 2026

Copy link
Copy Markdown
Member

Description: If a parent SD has no mappings, then StructureDefinition.originalMapping will be empty (e.g., []). During export, SDs are "cleaned" and properties that are empty arrays are deleted (since empty arrays are not allowed in FHIR). When originalMapping was deleted, however, the code that builds the mappings in snapshot mode crashes trying to dereference originalMapping. Now an undefined originalMapping will be treated as an empty array (which is what it was before cleaning).

Testing Instructions: You can reproduce this using the project from #1616:

git clone https://github.com/medizininformatik-initiative/kerndatensatzmodul-onkologie.git
cd kerndatensatzmodul-onkologie
git checkout dev
sushi . --snapshot  # crashes

On master it will crash but on this PR branch the build will succeed.

Related Issue: #1616

cmoesel added 2 commits March 28, 2026 09:35
In the case that an originalMapping is empty ([]), it might get cleaned and deleted. Usually this is ok, but when building snapshots, we reference it to build the mapping, so we need to treat an undefined originalMapping like [] if that occasion arises.

Fixes #1616
@jduteau
jduteau merged commit 48532f4 into master Apr 15, 2026
14 checks passed
@jduteau
jduteau deleted the fix-snapshot-error branch April 15, 2026 16:09
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.

2 participants