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

Conditional PATCH returns NullPointerException #3773

Closed
renom opened this issue Jul 12, 2022 · 3 comments
Closed

Conditional PATCH returns NullPointerException #3773

renom opened this issue Jul 12, 2022 · 3 comments
Assignees
Labels
bug Something isn't working P1 Priority 1 - Must Have

Comments

@renom
Copy link

renom commented Jul 12, 2022

Request: PATCH /fhir-server/api/v4/Patient?_id={existing_id}

Response:

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "exception",
            "details": {
                "text": "NullPointerException: <null message>"
            }
        }
    ]
}

There's the same error when different filters are passed.

@renom renom added the bug Something isn't working label Jul 12, 2022
@lmsurpre lmsurpre self-assigned this Jul 12, 2022
@lmsurpre lmsurpre added the P1 Priority 1 - Must Have label Jul 12, 2022
@lmsurpre
Copy link
Member

lmsurpre commented Jul 12, 2022

I was able to reproduce it and captured the following stack trace:

[INFO]     java.lang.NullPointerException: Cannot invoke "com.ibm.fhir.model.resource.Resource.getId()" because "newResource" is null
[INFO] 	at com.ibm.fhir.server.util.FHIRRestHelper.doUpdateMeta(FHIRRestHelper.java:619)
[INFO] 	at com.ibm.fhir.server.util.FHIRRestHelper.doPatchOrUpdate(FHIRRestHelper.java:484)
[INFO] 	at com.ibm.fhir.server.util.FHIRRestHelper.doPatch(FHIRRestHelper.java:438)
[INFO] 	at com.ibm.fhir.server.resources.Patch.conditionalPatch(Patch.java:276)
...

lmsurpre added a commit that referenced this issue Jul 12, 2022
Signed-off-by: Lee Surprenant <lmsurpre@merative.com>
lmsurpre added a commit that referenced this issue Jul 13, 2022
issue #3773 - add guard to avoid NPE for conditional patch
@lmsurpre
Copy link
Member

lmsurpre commented Aug 4, 2022

QA: test both JSONPatch and FHIRPathPatch and confirm no NPE

@PrasannaHegde1
Copy link
Collaborator

PrasannaHegde1 commented Aug 8, 2022

tried condition PATCH with both JSONPatch and FHIRPathPatch with below requests.
JSONPatch:
Request: PATCH /fhir-server/api/v4/Patient?name=Dave
Requesy body : [{ "op": "add", "path": "/gender", "value": "male" }]
Response : 200 OK. No null pointer exception observed.
3733_json_patch

FHIRPathPatch:
Request: PATCH /fhir-server/api/v4/Patient?name=Dave
Requesy body :

{
    "resourceType": "Parameters",
    "id": "test",
    "parameter": [
        {
            "name": "operation",
            "part": [
                {
                    "name": "type",
                    "valueCode": "replace"
                },
                {
                    "name": "path",
                    "valueString": "Patient.gender"
                },
                {
                    "name": "value",
                    "valueCode": "male"
                }
            ]
        }
    ]
}

Response : 200 OK. No null pointer exception observed.
3733_fhirpath_patch

This is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 Priority 1 - Must Have
Projects
None yet
Development

No branches or pull requests

3 participants