Skip to content

Bug: Validation with unknown profile cause error even when setting FhirInstanceValidator.setErrorForUnknownProfiles(false) #7338

@ttnTrifork

Description

@ttnTrifork

The Problem

It seems that the fix for #6607 introduced a new validation error, but does not check if the validator is configured to give error for unknown profiles or not.

The #6607 fix was ensuring that the $validate operation SHALL return an error if the resource could not be validated against the input profile parameter, which is fair.

But this new validation error is also produced when creating/updating a resource if a RepositoryValidatingInterceptor (with a RequireValidationRule) or a RequestValidatingInterceptor (that adds the FhirInstanceValidator as a validator module) is registered on the server.

This means that now the create/update request fails and the resource is not persisted even if having configured FhirInstanceValidator.setErrorForUnknownProfiles(false) on the "myInstanceValidator" IInstanceValidatorModule Spring bean.
Prior to HAPI 8.2 this worked as expected.

See https://github.com/hapifhir/hapi-fhir/blob/master/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/ValidatorWrapper.java#L262-L266
m.setLevel(ValidationMessage.IssueSeverity.ERROR);

The Solution

For other profile errors, ValidatorWrapper consults the myErrorForUnknownProfiles boolean property (which comes from the FhirInstanceValidator property with same name).

I am happy to open a PR that adds a check for the property when setting the severity of the new validation message, while still ensuring $validate returns an error severity issue if target profile is unknown, regardless of the value of myErrorForUnknownProfiles

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions