whosonfirst / whosonfirst-www-api

4 stars 2 forks source link

Got a 500 error for getHierarchiesByLatLon against 36.7232166,-4.3704579 #51

Closed simonw closed 7 years ago

simonw commented 7 years ago

For the following URL:

https://whosonfirst-api.mapzen.com/?extras=geom%3Abbox%2Cwof%3Ahierarchy&latitude=36.7232166&spr=1&api_key=mapzen-xxx&method=whosonfirst.places.getHierarchiesByLatLon&longitude=-4.3704579

I get back a 500 error with an empty response body (which my JSON parser then choked on).

HTTP/1.1 500 Internal Server Error
Content-Type: text/html
Date: Tue, 27 Jun 2017 23:05:56 GMT
Server: nginx/1.4.6 (Ubuntu)
X-ApiaxleProxy-Qpd-Left: 24823
X-ApiaxleProxy-Qpm-Left: 297
X-ApiaxleProxy-Qps-Left: 5
x-powered-by: PHP/5.5.9-1ubuntu4.21
Content-Length: 0
Connection: keep-alive

It would be nicer if this error included a valid JSON body giving an idea as to what went wrong.

I played around with the arguments and found that once I lose the "spr=1" argument the error goes away, and I get back this response instead:

{
    "hierarchies": [
        {
            "region_id": -1,
            "continent_id": -1,
            "country_id": 85633129,
            "locality_id": 101748185,
            "county_id": -1,
            "neighbourhood_id": 85863513
        }
    ],
    "stat": "ok"
}

So it looks like this is caused by the spr=1 argument, which was introduced relatively recently in this commit: https://github.com/whosonfirst/whosonfirst-www-api/commit/8a1a5cd866b203806e2bd5594d06e8c8486220e8

thisisaaronland commented 7 years ago

Blurp! I will look at this shortly...

thisisaaronland commented 7 years ago

Apologies. I wish I could tell you that this was an exciting and challenging bug, but it was just bad internet-typing on my part...

curl -X GET 'https://whosonfirst-api.mapzen.com?method=whosonfirst.places.getHierarchiesByLatLon&api_key=mapzen-xxxxxx&latitude=36.7232166&longitude=-4.3704579&spr=1&extras=geom:bbox,wof:hierarchy&format=json'

{
  "hierarchies": [
    {
      "region": [],
      "continent": [],
      "country": {
        "wof:id": 85633129,
        "wof:parent_id": "102191581",
        "wof:name": "Spain",
        "wof:placetype": "country",
        "wof:country": "ES",
        "wof:repo": "whosonfirst-data",
        "geom:bbox": "-18.167226,27.642239,4.337087,43.793443",
        "wof:hierarchy": [
          {
            "continent_id": 102191581,
            "country_id": 85633129
          }
        ]
      },
      "locality": {
        "wof:id": 101748185,
        "wof:parent_id": "404339241",
        "wof:name": "Málaga",
        "wof:placetype": "locality",
        "wof:country": "ES",
        "wof:repo": "whosonfirst-data",
        "geom:bbox": "-4.51515408868,36.6574349731,-4.382916,36.7612920779",
        "wof:hierarchy": [
          {
            "region_id": 85682787,
            "continent_id": 102191581,
            "localadmin_id": "404339241",
            "country_id": 85633129,
            "macroregion_id": "404227361",
            "locality_id": 101748185
          }
        ]
      },
      "county": [],
      "neighbourhood": {
        "wof:id": 85863513,
        "wof:parent_id": "101748185",
        "wof:name": "Valle Los Galanes",
        "wof:placetype": "neighbourhood",
        "wof:country": "ES",
        "wof:repo": "whosonfirst-data",
        "geom:bbox": "-4.37926836525,36.7079825529,-4.3662195699,36.7270838366",
        "wof:hierarchy": [
          {
            "region_id": -1,
            "continent_id": -1,
            "country_id": 85633129,
            "locality_id": 101748185,
            "county_id": -1,
            "neighbourhood_id": 85863513
          }
        ]
      }
    }
  ],
  "stat": "ok"
}