hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2k stars 1.31k forks source link

ResponseValidation uses different validation message severities for the same message depending on the server’s language. #3064

Open kairosmike opened 2 years ago

kairosmike commented 2 years ago

Bug description: ResponseValidation uses different validation message severities for the same message depending on the server’s language. The same validation message on an English system has the issue severity ERROR, but on a German system the severity WARNING. This means that some FHIR message responses are returned only on German systems, but are blocked by the response validation with validation message of sverity ERROR on English systems.

Where: Responsible for the severity change is org.hl7.fhir.common.hapi.validation.validator.ValidatorWrapper L182 (v.5.0.3) https://github.com/hapifhir/hapi-fhir/blob/v5.0.2/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/ValidatorWrapper.java or L199 (master) https://github.com/hapifhir/hapi-fhir/blob/master/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/ValidatorWrapper.java

if (message.endsWith("\" could not be resolved, so has not been checked") && next.getLevel() == ValidationMessage.IssueSeverity.WARNING) {
    next.setLevel(ValidationMessage.IssueSeverity.ERROR);
}

Expected Fix: If severity level switches necessary at all, decide it by a message code, not by a multilingualized message text of only one language. The validation behavior has to be independent from the server language.

patrick-werner commented 2 years ago

Good catch! Unknown Profiles can't create warnings in languages other than english. Unfortunately the underlying Java Validator only reports a generic coding on this issue.

I think the easiest fix would be to forward the setting to the core validator, and not do Severity changes inside the hapi code. @jamesagnew do you agree?