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

Null pointer on custom operations invoked at the resource-type level for resource types that don't exist #2307

Closed
d0roppe opened this issue Apr 30, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@d0roppe
Copy link
Collaborator

d0roppe commented Apr 30, 2021

Describe the bug
A clear and concise description of what the bug is.
I was testing with a bundle and got a null pointer error.

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

Environment
Which version of IBM FHIR Server?

To Reproduce
This was in postman, but here is the curl:
Data is mock data.

curl --location --request POST 'https://localhost:9443/fhir-server/api/v4/bundle/$validate' \
--header 'X-FHIR-TENANT-ID: default' \
--header 'Content-Type: application/json' \
--header 'X-FHIR-FORWARDED-URL: https://minions-r.us' \
--header 'prefer: return=OperationOutcome' \
--header 'Authorization: Basic ...' \
--data-raw '{
  "resourceType":"Bundle",
  "type":"batch",
  "entry":[
    {
      "resource":{
        "resourceType":"Claim",

        "id":"my-Sniff-Test-R1",
        "status":"active",
        "type":{
          "coding":[
            {
              "system":"http://terminology.hl7.org/CodeSystem/claim-type",
              "code":"professional"
            }
          ]
        },
        "use":"claim",
        "patient":{
          "reference":"Patient/my-Sniff-Test-P1"
        },
        "created":"2020-02-28T00:00:00+00:00",
        "insurer":{
          "reference":"Organization/1601660375-0ef3e098-3af0-456b-8330-4bb5885d14e7-Payer",
          "display":"XXX Health Plan"
        },
        "insurance":[
          {
            "sequence":2,
            "focal":true,
            "coverage":{
              "reference":"Coverage/1601660375-6e1cfe4e-6eca-46dd-adad-e75ff9466ea6-Coverage"
            }
          }
        ],
        "provider":{
          "reference":"Organization/1601660375-4961efdc-1404-4fe7-8b80-4a32849a3d59-Provider",
          "display":"XXX Health Plan"
        },
        "priority":{
          "coding":[
            {
              "system":"http://terminology.hl7.org/CodeSystem/process-priority",
              "code":"normaly"
            }
          ]
        }
      },
      "request":{
        "method":"PUT",
        "url":"Claim/my-Sniff-Test-R1"
      }
    },
    {
      "resource":{
        "resourceType":"ExplanationOfBenefit",
        "id":"my-Sniff-Test-R2",
        "language":"en-US",
        "text":{
          "status":"generated",
          "div":"<div xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\"><p>Empty for now - later use this field to increase file size</p></div>"
        },
        "status":"active",
        "type":{
          "coding":[
            {
              "system":"http://terminology.hl7.org/CodeSystem/claim-type",
              "code":"professional"
            }
          ],
          "text":"Outpatient Institution"
        },
        "use":"claim",
        "patient":{
          "reference":"Patient/my-Sniff-Test-P1"
        },
        "related":[
          {
            "reference":{
              "value":"Claim/my-Sniff-Test-R1"
            },
            "relationship":{
              "coding":[
                {
                  "system":"http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBRelatedClaimRelationshipCodes",
                  "code":"replacedby"
                }
              ]
            }
          }
        ],
        "claim":{
          "reference":"Claim/my-Sniff-Test-R1"
        },
        "billablePeriod":{
          "start":"2019-01-01T00:00:00+00:00",
          "end":"2021-10-31T00:00:00+00:00"
        },
        "created":"2020-02-08T00:00:00+00:00",
        "insurer":{
          "reference":"Organization/1601660375-0ef3e098-3af0-456b-8330-4bb5885d14e7-Payer",
          "display":"XXX Health Plan"
        },
        "provider":{
          "reference":"Organization/1601660375-4961efdc-1404-4fe7-8b80-4a32849a3d59-Provider",
          "display":"XXX Health Plan"
        },
        "outcome":"partial",
        "diagnosis":[
          {
            "sequence":1,
            "diagnosisCodeableConcept":{
              "coding":[
                {
                  "system":"http://hl7.org/fhir/us/carin-bb/ValueSet/CDCICD910CMDiagnosisCodes",
                  "code":"S06.0x1A"
                }
              ]
            },
            "type":[
              {
                "coding":[
                  {
                    "system":"http://terminology.hl7.org/CodeSystem/ex-diagnosistype",
                    "code":"principal"
                  }
                ]
              }
            ]
          }
        ],
        "insurance":[
          {
            "focal":true,
            "coverage":{
              "reference":"Coverage/1601660375-6e1cfe4e-6eca-46dd-adad-e75ff9466ea6-Coverage"
            }
          }
        ],
        "total":[
          {
            "category":{
              "coding":[
                {
                  "system":"http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBAdjudication",
                  "code":"paidtoprovider"
                }
              ],
              "text":"Payment Amount"
            },
            "amount":{
              "value":620,
              "currency":"USD"
            }
          },
          {
            "category":{
              "coding":[
                {
                  "system":"http://terminology.hl7.org/CodeSystem/adjudication",
                  "code":"submitted"
                }
              ],
              "text":"Submitted Amount"
            },
            "amount":{
              "value":2650,
              "currency":"USD"
            }
          },
          {
            "category":{
              "coding":[
                {
                  "system":"http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBAdjudication",
                  "code":"paidbypatient"
                }
              ],
              "text":"Patient Pay Amount"
            },
            "amount":{
              "value":0,
              "currency":"USD"
            }
          }
        ]
      },
      "request":{
        "method":"PUT",
        "url":"ExplanationOfBenefit/my-Sniff-Test-R2"
      }
    },
    {
      "resource":{
        "active":true,
        "address":[
          {
            "type":"physical",
            "country":"USA",
            "city":"Mabel",
            "line":[
              "114 South Main"
            ],
            "postalCode":"55954",
            "state":"MN"
          }
        ],
        "birthDate":"1996-02-04",
        "gender":"male",
        "id":"my-Sniff-Test-P1",
        "language":"en-US",
        "maritalStatus":{
          "coding":[
            {
              "code":"UNK",
              "system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor"
            }
          ]
        },
        "meta":{
          "lastUpdated":"2020-07-07T13:26:22.031421+00:00"
        },
        "name":[
          {
            "family":"Johnson",
            "given":[
              "BobsYouAunt"
            ]
          }
        ],
        "resourceType":"Patient",
        "telecom":[
          {
            "rank":2,
            "system":"phone",
            "value":"507-493-5001 x714"
          }
        ],
        "text":{
          "div":"<div xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\"><p>Empty for now - later use this field to increase file size</p></div>",
          "status":"generated"
        }
      },
      "request":{
        "method":"PUT",
        "url":"Patient/my-Sniff-Test-P1"
      }
    }
  ]
}'

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

@d0roppe d0roppe added the bug Something isn't working label Apr 30, 2021
@prb112 prb112 changed the title Null pointer on $validate of a bunle Null pointer on $validate of a Bundle Apr 30, 2021
@prb112
Copy link
Contributor

prb112 commented May 3, 2021

The URL above uses bundle which is not valid.

'https://localhost:9443/fhir-server/api/v4/Bundle/$validate' is the correct URL

@prb112
Copy link
Contributor

prb112 commented May 3, 2021

There is a call to getResourceType which does not check if the output is null. It assumes that this is never null.

            if (resourceTypeName != null) {
                resourceType = getResourceType(resourceTypeName);
            }

prb112 added a commit that referenced this issue May 3, 2021
- Add check for the URI Path
- Add Integration Test

Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
@prb112 prb112 self-assigned this May 3, 2021
@prb112 prb112 modified the milestones: Sprint 2021-07, Sprint 2021-06 May 3, 2021
@prb112
Copy link
Contributor

prb112 commented May 3, 2021

PR #2310

The message generated is:
Operation context RESOURCE_TYPE must include a valid ResourceType in the URL Path

This ensures invalid input isn't reflected back to the sender.

prb112 added a commit that referenced this issue May 3, 2021
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
prb112 added a commit that referenced this issue May 4, 2021
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
prb112 added a commit that referenced this issue May 7, 2021
Null pointer on $validate of a Bundle #2307
@d0roppe
Copy link
Collaborator Author

d0roppe commented May 10, 2021

With the fix loaded, reran the same statement, and now I get a 404 error with

{
  "resourceType": "OperationOutcome",
  "id": "c0-a8-1-79-e1bf3a96-3098-4750-a26b-d9314d14ad6a",
  "issue": [
    {
      "severity": "fatal",
      "code": "not-supported",
      "_code": {
        "extension": [
          {
            "url": "http://ibm.com/fhir/extension/not-supported-detail",
            "valueCode": "resource"
          }
        ]
      },
      "details": {
        "text": "&#39;bundle&#39; is not a valid resource type."
      }
    }
  ]
}

Closing the issue

@d0roppe d0roppe closed this as completed May 10, 2021
michaelwschroeder pushed a commit that referenced this issue May 11, 2021
- Add check for the URI Path
- Add Integration Test

Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
michaelwschroeder pushed a commit that referenced this issue May 11, 2021
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
michaelwschroeder pushed a commit that referenced this issue May 11, 2021
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
@lmsurpre lmsurpre changed the title Null pointer on $validate of a Bundle Null pointer on customer operations invoked at the resource-type level for resource types that don't exist May 17, 2021
@lmsurpre lmsurpre changed the title Null pointer on customer operations invoked at the resource-type level for resource types that don't exist Null pointer on custom operations invoked at the resource-type level for resource types that don't exist May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants