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

$validate fails hard with certain extension URLs #872

Closed
jmandel opened this Issue Feb 28, 2018 · 10 comments

Comments

Projects
None yet
4 participants
@jmandel
Contributor

jmandel commented Feb 28, 2018

The payload below is causing HAPI's validation to fail without a useful error message.

Note: the payload below isn't great (i.e. a ValueSet URI is being used as an extension URI), but I don't think it's technically invalid, and in any case HAPI's validate is breaking (so if you have this extension buried anywhere in a payload, the whole validation attempt fails without pointing to the cause).

$ cat err.json 
{
  "resourceType": "Patient",
  "extension": [
    {
      "url": "http://hl7.org/fhir/ValueSet/v3-ActInvoiceGroupCode",
      "valueString": "test"
    }
  ]
}
$ curl -X POST -H "Accept: application/fhir+json" -H "Content-type: application/fhir+json" 'http://hapi.fhir.org/baseDstu3/ExplanationOfBenefit/$validate' --data @err.json
{
  "resourceType": "OperationOutcome",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>Unexpected failure while validating resource</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
  },
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "Unexpected failure while validating resource"
    }
  ]
}
@aviars

This comment has been minimized.

aviars commented Feb 28, 2018

I see that changing the url to http://hl7.org/fhir/v3/ActCode/cs.html seems to get around this.

@jmandel

This comment has been minimized.

Contributor

jmandel commented Feb 28, 2018

Indeed changing to anything other than a FHIR defined ValueSet URL avoids the bug.

@grahamegrieve

This comment has been minimized.

Collaborator

grahamegrieve commented Feb 28, 2018

jamesagnew added a commit that referenced this issue Mar 1, 2018

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Mar 1, 2018

Well one thing is for certain. A wide variety of unit tests have failed to reproduce this.

I'm gonna have to dig through the server logs I think.

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Mar 1, 2018

Ok, I've replicated this now. It's not actually a validator issue, looks like HAPI JPA is returning this ValueSet in response to a StructureDefnition query for some reason. Still investigating why.

Also @jmandel it's not the root cause, but you need to escape your $ in that curl statement :)

jamesagnew added a commit that referenced this issue Mar 1, 2018

@jmandel

This comment has been minimized.

Contributor

jmandel commented Mar 1, 2018

Thanks! (Note, with single quotes as above, the $ is a literal!)

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Mar 1, 2018

Ahh I always get ' and " backwards. ha!

So this turns out to be a pretty fundamental bug in HAPI JPA. It turns out that if you perform a search with only parameters of type uri, the resource type doesn't get added to the SQL query. How has this managed to exist for so long?!

Fix incoming...

@jmandel

This comment has been minimized.

Contributor

jmandel commented Mar 1, 2018

Ooh, fascinating! I can kind of see why this managed to slip by for a long time, since URIs usually imply a resource type.

@jamesagnew jamesagnew closed this in a18303f Mar 1, 2018

@aviars

This comment has been minimized.

aviars commented Mar 21, 2018

@jamesagnew was this fix pushed to https://hapi.fhir.org/ ?

I still get the same error when I try to do a https://hapi.fhir.org/baseDstu3/ExplanationOfBenefit/$validate

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Mar 21, 2018

It had not. Thanks for the reminder, it has now.

See: http://hapi.fhir.org/baseDstu3/ExplanationOfBenefit/1311289/$validate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment