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

_history after $erase version returns FHIRPersistenceException: convertResourceDTO returned no resource #3439

Closed
kmbarton423 opened this issue Mar 7, 2022 · 5 comments
Assignees
Labels
bug Something isn't working P2 Priority 2 - Should Have

Comments

@kmbarton423
Copy link
Contributor

Executed an $erase of a specific version of a resource. Received 500 Internal Server Error when attempted to review the resource history after the erase.

GET .../Patient/[ID]/_history
{
"resourceType": "OperationOutcome",
"id": "ac-11-0-3-57354466-583e-4407-86e9-2679c80d6c31",
"issue": [
{
"severity": "fatal",
"code": "exception",
"details": {
"text": "FHIRPersistenceException: convertResourceDTO returned no resource for 'Patient/P0008'"
}
}
]
}

Working with the latest level of main.

Steps to reproduce the behavior:

  1. Store three versions of a resource ... Patient/[ID]
  2. Erase version 2 of Patient/[ID]
  3. Attempt to review resource history ... Patient/[ID]/_history
  4. See error
@kmbarton423 kmbarton423 added the bug Something isn't working label Mar 7, 2022
@kmbarton423
Copy link
Contributor Author

attachment contains stack trace

historyError.txt

@lmsurpre
Copy link
Member

if it proves problematic, we should consider removing support for erasing a particular version of a particular resource

@punktilious
Copy link
Collaborator

After erasing a specific version of a Patient using:

curl -k -i \
-H 'Content-Type: application/json' \
-H 'X-FHIR-TENANT-ID: a-tenant-name' \
-X POST \
-u 'some-credentials' '.../fhir-server/api/v4/Patient/patient1/$erase' -d '
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "patient",
      "valueString": "patient1"
    },
    {
      "name": "reason",
      "valueString": "My Reason for removing this resource"
    },
    {
      "name": "version",
      "valueInteger": 2
    }
  ]
}'

we get

fhirdb=> select resource_id, version_id, is_deleted, length(data) from fhirdata.patient_resources where logical_resource_id = 6607002;
 resource_id | version_id | is_deleted | length 
-------------+------------+------------+--------
     6607001 |          1 | N          |    170
     6610001 |          2 | N          |       
     6611001 |          3 | Y          |       
     6614001 |          4 | N          |    170
     6617001 |          5 | N          |    170

showing that the data column is nulled out for version 2 (note that we have also done a soft-delete of version 3 in this case.

@punktilious
Copy link
Collaborator

punktilious commented Mar 14, 2022

If we update a Condition with a versioned reference pointing to the erased patient, we see a similar error if we perform a search with _include

fhir-server/api/v4/Condition?_id=condition1&_include=Condition:subject

yields:

convertResourceDTO returned no resource for 'Patient/patient1'
com.ibm.fhir.persistence.exception.FHIRPersistenceException: convertResourceDTO returned no resource for 'Patient/patient1'  [probeId=7f-0-0-1-efe98043-bc4f-460c-a5a5-8288653e8cba]
        at com.ibm.fhir.persistence.jdbc.impl.FHIRPersistenceJDBCImpl.convertResourceDTOList(FHIRPersistenceJDBCImpl.java:1470)
        at com.ibm.fhir.persistence.jdbc.impl.FHIRPersistenceJDBCImpl.search(FHIRPersistenceJDBCImpl.java:745)

The problem becomes how to handle a resource record that has no data. This has implications for pagination (e.g. search counts) so is something that would need to be filtered out in the query.

punktilious added a commit that referenced this issue Mar 15, 2022
Signed-off-by: Robin Arnold <robin.arnold@ibm.com>
punktilious added a commit that referenced this issue Mar 15, 2022
Signed-off-by: Robin Arnold <robin.arnold@ibm.com>
punktilious added a commit that referenced this issue Mar 16, 2022
Signed-off-by: Robin Arnold <robin.arnold@ibm.com>
@tbieste
Copy link
Contributor

tbieste commented Mar 21, 2022

I verified that getting history of a resource when a version of the resource has been erased no longer results in an HTTP 500 error; instead that version of the resource marked as deleted in the returned bundle.
I also verified that if a versioned resource pointed to an erased resource version, that the _include doesn't result in a HTTP 500 error either.
Marking as closed.

@tbieste tbieste closed this as completed Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 Priority 2 - Should Have
Projects
None yet
Development

No branches or pull requests

4 participants