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

Referenced to contained resources are always validated, ignoring policyAdvisor #1903

Open
dotasek opened this issue Feb 13, 2025 · 3 comments

Comments

@dotasek
Copy link
Collaborator

dotasek commented Feb 13, 2025

If a reference is made to a contained resource, the core validator ignores the policyAdvisor.policyForContained method, and always validates the contained resource.

The logic appears to be here:

if (refType.equals("contained") || refType.equals("bundled")) {

A test case that illustrates this has been created here: FHIR/fhir-test-cases#216

@dotasek
Copy link
Collaborator Author

dotasek commented Feb 20, 2025

After discussion with @grahamegrieve, the policyForReference method should in fact supersede the policyForContained method, so this will not be changed.

However, the policyForReference method could be changed to include an enum as a parameter as follows:

ReferenceValidationPolicy policyForReference(
  IResourceValidator validator,
  Object appContext,
  String path,
  String url, 
  ReferenceType referenceType
);

public enum ReferenceType {
    CONTAINED,
    REMOTE,
    BUNDLED
  }

This would allow the implementation of IValidationPolicyAdvisor to define logic depending on the type of reference being validated.

@jdar8
Copy link
Collaborator

jdar8 commented Feb 20, 2025

Hi @grahamegrieve,

Thanks for looking into this!
I think its great to make the validation behaviour for references configurable.

That being said, I'm a little curious as to why the policyForReference method should in fact supersede the policyForContained.
I just want to make sure that custom implementations of IValidationPolicyAdvisor (for example, one that will ignore validation for contained or bundled references) won't cause any unintentional consequences.

@grahamegrieve
Copy link
Collaborator

it's a lineball call, I think, but it's about least surprise. policyForContained concerns hitting a contained resource while iterating the resource directly. That's self evident

policyForReference concerns what do when hitting a reference, and deciding whether it should be validated or not

So when a reference points to a contained resource, which has precedence? I think that policyForReference should behave consistently irrespective of the location of the target, whether it's contained or not.

What would be good is to document this explicitly, so I'll do that

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

No branches or pull requests

3 participants