Skip to content

Handle null values in fhir-server-config and throw for exceptional case#2822

Merged
lmsurpre merged 4 commits into
mainfrom
lee-main
Oct 5, 2021
Merged

Handle null values in fhir-server-config and throw for exceptional case#2822
lmsurpre merged 4 commits into
mainfrom
lee-main

Conversation

@lmsurpre
Copy link
Copy Markdown
Member

@lmsurpre lmsurpre commented Oct 1, 2021

Previously, we'd throw an IllegalStateException if we encountered a
null value. This came up because the helm toJson function produces all
possible fields for an object, even when some are null.

Additionally, if we have an invalid config (such as described above), in
FHIRRestHelper.validateResource we were swallowing the underlying
exception and instread constructing a generic OperationOutcomeIssue with
message "Error retrieving profile configuration". This meant we were missing
the root cause in our logs and also meant that this exception was being handled
just like any other validation error and so, even though it was a server
config issue, this was not clear to the client.

Signed-off-by: Lee Surprenant lmsurpre@us.ibm.com

Previously, we'd through an IllegalStateException if we encountered a
null value. This came up because the helm `toJson` function produces all
possibly fields for an object, even when some are null.

If we have an invalid config (such as described above), in
FHIRRestHelper.validateResource we were swallowing the underlying
exception and instread constructing a generic OperationOutcomeIssue with
message "Error retrieving profile configuration". This was being handled
just like any other validation error and so, even though it was a server
config issue, this was not clear to the client.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
Comment thread fhir-config/src/main/java/com/ibm/fhir/config/PropertyGroup.java
Now that convertJsonValue can return null, this is safer/easier than
updating all the callers to be able to handle null.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
Previously this method returned null for missing properties, but
JsonValue.NULL for properties that exist in the config with a literal
value of null. We had null checks in all the getTypedProperty methods
that call this one, but none of them handled `JsonValue.NULL` and so
I've updated this one spot.

I also added unit test coverage for both PropertyGroup and
FHIRConfigHelper

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
Copy link
Copy Markdown
Contributor

@michaelwschroeder michaelwschroeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread fhir-config/src/main/java/com/ibm/fhir/config/PropertyGroup.java Outdated
Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>

Co-authored-by: Michael W Schroeder <66479070+michaelwschroeder@users.noreply.github.com>
@lmsurpre lmsurpre merged commit 5b64365 into main Oct 5, 2021
@lmsurpre lmsurpre deleted the lee-main branch October 5, 2021 01:46
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.

4 participants