GIScience/ohsome-api

Inconsistent behavior in /ratio endpoint regarding filter2 parameter

apibugsreporting opened this issue · 0 comments

Bug Description

In the /elements/count/ratio/groupBy/boundary endpoint, sometimes when not using the filter2 parameter, an error is returned. Some other times, the request is successful and data is returned.

General Information

Please include the following general information about the issue and list any additional steps needed to reproduce the bug.

  • Version of the ohsome API [e.g. 1.5.0]
    • 1.6.1
  • Which API instance was requested [e.g. remote instance at https://api.ohsome.org/v1, local instance with an h2 file or connected to the cluster, etc.]
    • Remote instance at https://api.ohsome.org/v1
  • Affected endpoint(s) [e.g. /contributions/count]
    • /elements/count/ratio/groupBy/boundary
  • URL of your request (and request body if applicable)
    • https://api.ohsome.org/v1/elements/count/ratio/groupBy/boundary?filter=oneway%21%3D*%20and%20id%3A%281%20..%209999%29&types2=point%2Cline%2C&format=json&showMetadata=true&time=2009-05-02&keys2=highway&timeout=60&values2=track&bcircles=lf%3A8.704%2C49.4055%2C2%7Cj%3A8.705303%2C49.412%2C3%7Cc%3A8.704%2C49.4060%2C88
  • Used HTTP method [GET or POST]
    • Both
  • Utilized tool/library for the request [e.g. cURL, Postman, ohsome-py, etc.]

Expected Behaviour

With the previous request, the following response body is obtained:

{
    "timestamp": "2021-10-31T06:39:03.01736",
    "status": 400,
    "message": "The filter2 parameter has to be defined when using a /ratio endpoint.",
    "requestUrl": "https://api-test.ohsome.org/v1/elements/count/ratio/groupBy/boundary?filter=oneway%21%3D*%20and%20id%3A%281%20..%209999%29&types2=point%2Cline%2C&format=json&showMetadata=true&time=2009-05-02&keys2=highway&timeout=60&values2=track&bcircles=lf%3A8.704%2C49.4055%2C2%7Cj%3A8.705303%2C49.412%2C3%7Cc%3A8.704%2C49.4060%2C88"
}

However, when making the following request: https://api.ohsome.org/v1/elements/count/ratio/groupBy/boundary?keys=highway&types2=point%2Cother&values=secondary&timeout=85&bcircles=8.7450%2C49.435%2C5%7C8.723%2C49.408%2C1

Which does NOT include the filters2 parameter, a successful response is obtained:

{
    "attribution": {
        "url": "https://ohsome.org/copyrights",
        "text": "© OpenStreetMap contributors"
    },
    "apiVersion": "1.6.1",
    "groupByBoundaryResult": [
        {
            "groupByObject": "boundary1",
            "ratioResult": [
                {
                    "timestamp": "2021-07-25T21:00:00",
                    "value": 0.0,
                    "value2": 0.0,
                    "ratio": "NaN"
                }
            ]
        },
        {
            "groupByObject": "boundary2",
            "ratioResult": [
                {
                    "timestamp": "2021-07-25T21:00:00",
                    "value": 0.0,
                    "value2": 0.0,
                    "ratio": "NaN"
                }
            ]
        }
    ]
}

Further Information

Additional Information

Test report of the API request obtaining a client error response:

Test report of the API request obtaining a successful response: