Closed cames-be closed 6 months ago
@cames-be I assume this was from your own code calling the serializers and not via a regular API or the FhirClient right? And those 2 snippits should be enough to have in a unit test to verify it?
@brianpos
I assume this was from your own code calling the serializers and not via a regular API or the FhirClient right?
Yes, it is our code calling the serializers directly. We have run into memory pressure issues when deserializing large Bundle resources in their entirety, so instead we deserialize the individual Bundle.EntryComponent instances while processing.
And those 2 snippits should be enough to have in a unit test to verify it?
Yes, the two code examples were provided with unit tests in mind.
Describe the bug A bug was introduced in https://github.com/FirelyTeam/firely-net-sdk/issues/2414 where only FHIR resources at the root element can be deserialized, but resources found as sub-elements of a non-resource component will fail. This was tested on both
Bundle.EntryComponent
andParameters.ParameterComponent
, but would apply to any element class that derives fromBackBoneElement
and contains aResource
.When attempting to deserialize a
Bundle.EntryComponent
or aParameters.ParameterComponent
that has a validResource
property set, the PathStack class will throw an exception. During deserialization the class will push on the_paths
member whenEnterElement
is called and not push whenEnterResource
is called due to the_paths
member already having an entry. Then, whenExitResource
is called it will_paths.Pop()
and then again whenExitElement
is called which causes the exception.To Reproduce Deserialization of
Bundle.EntryComponent
Deserialization of
Parameters.ParameterComponent
Expected behavior A valid deserialized object is returned and no exception is thrown.
Version used:
Additional context Prior to popping from the
_paths
Stack object, it should verify that there is an entry to pop. https://github.com/FirelyTeam/firely-net-sdk/blob/main/src/Hl7.Fhir.Base/Serialization/PathStack.cs#L103