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

Search with malformed parameters should produce 200 result? #309

Open
andy-a-o opened this issue Nov 30, 2020 · 0 comments
Open

Search with malformed parameters should produce 200 result? #309

andy-a-o opened this issue Nov 30, 2020 · 0 comments
Labels

Comments

@andy-a-o
Copy link
Contributor

andy-a-o commented Nov 30, 2020

Describe the bug
Passing a malformed search parameter produces 400 result.

To Reproduce
POST http://localhost:5000/fhir/Patient/_search?...=foobar&_format=application/fhir%2Bjson

Result:

{
   "resourceType":"OperationOutcome",
   "issue":[
      {
         "severity":"error",
         "diagnostics":"Could not parse parameter [(..., foobar)] for reason [Supplied an empty search parameter name or chain (Parameter 'key')]."
      },
      {
         "severity":"error",
         "diagnostics":"Exception of type 'Spark.Engine.Core.SparkException' was thrown."
      }
   ]
}

Expected behavior

To return 200 + some operation outcome, like warning, as it's done in https://vonk.fire.ly/:

{
    "resourceType": "Bundle",
    "type": "searchset",
    "entry": [
        {
            "fullUrl": "https://vonk.fire.ly/Patient/pat921jd136",
            "search": {
                "mode": "match"
            },
            "resource": {
                "resourceType": "Patient",
                "id": "pat921jd136",
                "address": [
                    {
                        "postalCode": "96120"
                    }
                ],
                "birthDate": "1998-09-18",
                "deceasedBoolean": true,
                "gender": "other",
                "identifier": [
                    {
                        "system": "http://fhir.de/NamingSystem/gkv/kvid-10",
                        "value": "A536135075"
                    }
                ],
                "name": [
                    {
                        "family": "Glover",
                        "given": [
                            "Reggi"
                        ],
                        "text": "Reggi Glover",
                        "use": "official"
                    }
                ],
                "meta": {
                    "versionId": "bbc324e1-0ce3-4cb5-a9a6-93c3d8920341",
                    "lastUpdated": "2020-11-28T10:06:11.032+00:00"
                }
            }
        },
        {
            "fullUrl": "https://vonk.fire.ly/Patient/54eb1d93-360b-4477-a322-ded4d513ff7c",
            "search": {
                "mode": "match"
            },
            "resource": {
                "resourceType": "Patient",
                "text": {
                    "status": "generated",
                    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Some narrative</div>"
                },
                "identifier": [
                    {
                        "system": "http:/example.org/fhir/ids",
                        "value": "234234"
                    }
                ],
                "active": true,
                "name": [
                    {
                        "use": "official",
                        "family": "Chalmers",
                        "given": [
                            "Peter",
                            "James"
                        ]
                    }
                ],
                "gender": "male",
                "birthDate": "1974-12-25",
                "id": "54eb1d93-360b-4477-a322-ded4d513ff7c",
                "meta": {
                    "versionId": "9cdba4a2-a3fb-4146-8550-9d3f5fbaa1d4",
                    "lastUpdated": "2020-11-25T18:47:53.226+00:00"
                }
            }
        },
        {
            "fullUrl": "https://vonk.fire.ly/Patient/bc57d1cd-3e27-4728-99bd-4206d74d5fdd",
            "search": {
                "mode": "match"
            },
            "resource": {
                "resourceType": "Patient",
                "text": {
                    "status": "generated",
                    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Some narrative</div>"
                },
                "active": true,
                "name": [
                    {
                        "use": "official",
                        "family": "Chalmers",
                        "given": [
                            "Peter",
                            "James"
                        ]
                    }
                ],
                "gender": "male",
                "birthDate": "1974-12-25",
                "id": "bc57d1cd-3e27-4728-99bd-4206d74d5fdd",
                "meta": {
                    "versionId": "45d48da6-99ee-4e70-8852-12318a93e56c",
                    "lastUpdated": "2020-11-25T18:47:53.170+00:00"
                }
            }
        },
        {
            "fullUrl": "https://vonk.fire.ly/OperationOutcome/6f24a796-2277-4895-addc-c11ed3e36e29",
            "search": {
                "mode": "outcome"
            },
            "resource": {
                "resourceType": "OperationOutcome",
                "id": "6f24a796-2277-4895-addc-c11ed3e36e29",
                "meta": {
                    "versionId": "df98c94e-ca90-4e88-a2a9-25787ee4c915",
                    "lastUpdated": "2020-11-30T07:48:14.883+00:00"
                },
                "issue": [
                    {
                        "severity": "error",
                        "code": "exception",
                        "details": {
                            "coding": [
                                {
                                    "system": "http://hl7.org/fhir/dotnet-api-operation-outcome",
                                    "code": "5006"
                                }
                            ],
                            "text": "Parameter is not well formatted, expected 'parametername[:modifier]=value'."
                        }
                    }
                ]
            }
        }
    ],
    "total": 3,
    "link": [
        {
            "relation": "self",
            "url": "https://vonk.fire.ly/Patient/_search?_format=application/fhir+json&_sort=-_lastUpdated&_count=10&_skip=0"
        }
    ],
    "id": "bc151c42-8814-4c12-a5fa-733bce0015cb",
    "meta": {
        "versionId": "1b34809a-2a56-4cb3-b8e3-9995e0fc9a02",
        "lastUpdated": "2020-11-30T07:48:14.877+00:00"
    }
}

Spec says this:

2.1.1.3 Handling Errors
If a server is unable to execute a search request, it may return an error. A HTTP status code of 403 signifies that the server refused to perform the search, while other 4xx and 5xx codes signify that some sort of error has occurred. When the search fails, a server SHOULD return an OperationOutcome detailing the cause of the failure. Note: An empty search result is not a failure.
In some cases, parameters may cause an error. For instance:
A parameter may refer to a non-existent resource e.g. GET [base]/Observation?subject=101, where "101" does not exist
A parameter may refer to an unknown code e.g. GET [base]/Observation?code=loinc|1234-1, where the LOINC code "1234-1" is not known to the server
A parameter may refer to a time that is out of scope e.g. GET [base]/Condition?onset=le1995, where the system only has data going back to 2001
A parameter may use an illegal or unaaceptable modifier e.g. GET [base]/Condition?onset:text=1995, where the modifier cannot be processed by the server
A data time parameter may have incorrect format e.g. GET [base]/Condition?onset=23%20May%202009
Where the content of the parameter is syntactically correct, servers SHOULD return an error. However where the issue is a logical condition (e.g. unknown subject or code), the server SHOULD process the search, including processing the parameter - with the result of returning an empty search set, since the parameter cannot be satisfied.
In such cases, the search process MAY include an OperationOutcome in the search set that contains additional hints and warnings about the search process. This is included in the search results as an entry with search mode = outcome. Clients can use this information to improve future searches.

Failed tests
SprinklerSearchTest (SE25P, SE25G)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants