Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Oct 5, 2021

Conversation

lmsurpre
Copy link
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>
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
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

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