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

Add support for POST of empty objects #2222

Closed
csandersdev opened this issue Apr 8, 2021 · 3 comments
Closed

Add support for POST of empty objects #2222

csandersdev opened this issue Apr 8, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@csandersdev
Copy link
Contributor

I encountered an issue where the CQL engine we are using tried to do a POST to /ValueSet/<someid>/$expand with an empty parameters object (e.g. {"resourceType": "Parameters"}) and the IBM FHIR server failed to process the request because of the empty object. For example...

$ curl -X POST -H 'Content-Type: application/json' -d '{"resourceType":"Parameters"}' 'https://localhost:9443/fhir-server/api/v4/ValueSet/2.16.840.1.113883.3.464.1003.108.12.1001/$expand'

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "invalid",
            "details": {
                "text": "FHIRProvider: global-1: All FHIR elements must have a @value or children"
            },
            "expression": [
                "<no expression>"
            ]
        }
    ]
}

Describe the solution you'd like
Parsing of empty objects was discussed in Zuplip here and turned into an issue that was voted on and approved for FHIR R4B here. I propose that we add support for empty objects to IBM FHIR in support of this vote.

Describe alternatives you've considered
As a workaround, clients can generally convert a request with an empty parameters body from POST to GET, but the spec allows this only when operations have the "affectsState" property set to false. The affectsState property does not seem to be widely used, so it is difficult to use this to determine behavior at runtime.

Acceptance Criteria
1.
WHEN the user does a POST to an operation with an empty parameters object
THEN the FHIR server will successfully parse the parameters and pass the object along to the operation

@lmsurpre lmsurpre self-assigned this Apr 8, 2021
lmsurpre added a commit that referenced this issue Apr 8, 2021
Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre added a commit that referenced this issue Apr 8, 2021
Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
@prb112 prb112 added the enhancement New feature or request label Apr 8, 2021
@lmsurpre lmsurpre added this to the Sprint 2021-05 milestone Apr 8, 2021
lmsurpre added a commit that referenced this issue Apr 8, 2021
Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre added a commit that referenced this issue Apr 8, 2021
Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
@prb112
Copy link
Contributor

prb112 commented Apr 12, 2021

curl --location --request POST 'https://localhost:9443/fhir-server/api/v4/$reindex?resourceCount=1' \
--header 'X-FHIR-TENANT-ID: default' \
--header 'Content-Type: application/fhir+json' \
--header 'Authorization: Basic ....' \
--data-raw '{"resourceType":"Parameters"}'

Received 200 back and the correct response.

proceeding to negative tests

@prb112
Copy link
Contributor

prb112 commented Apr 12, 2021

Negative Test

curl --location --request POST 'https://localhost:9443/fhir-server/api/v4/Patient' \
--header 'Content-Type: application/fhir+json' \
--header 'Authorization: Basic ....' \
--data-raw '{
    "resourceType": "Patient"
}'
{
    "resourceType": "Patient"
}

@prb112
Copy link
Contributor

prb112 commented Apr 12, 2021

That is actually valid. So we're all set.

@prb112 prb112 closed this as completed Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants