microsoft / fhir-server

A service that implements the FHIR standard
MIT License
1.17k stars 501 forks source link

Narrative HTML validation ignores some errors #3100

Open michael-wilson-au opened 1 year ago

michael-wilson-au commented 1 year ago

Describe the bug The HTML validation of a resource narrative can ignore errors that should be raised.

If the narrative contains html errors that should be ignored the validation function exits without completing the rest of the validation which may find additional errors that shouldn't be ignored.

FHIR Version? Core

Data provider? N/A

To Reproduce Steps to reproduce the behavior:

  1. Create a FHIR resource (i.e. Patient) with a text narrative containing html errors that can be ignored by the narrative html validator as well as html errors that cannot be ignored:
    {
    "resourceType": "Patient",
    "id": "example",
    "text": {
    "status": "generated",
    "div": "<div><!-- Comment ended with a dash. This error should be ignored --->\"><not_valid_tag>This tag should return validation error</not_valid_tag></div>"
    },
    "name": [
    {
      "family": "Windsor",
      "given": [
        "Peter",
        "James"
      ]
    }
    ]
    }
  2. Create the resource POST {{fhirurl}}/Patient

Expected behavior 400 Bad Request response for "Illegal element name 'NOT_VALID_TAG'."

Actual behavior 201 Created response

AB#101209

EXPEkesheth commented 1 year ago

Thanks for reporting the issue, we will take a look and respond

michael-wilson-au commented 1 year ago

I have submitted PR #3101 to resolve this issue