wttr.in
wttr.in copied to clipboard
"Unknown Location" errors do not follow requested `format` nor `lang`
The format is handled in the lines below, but this is always sent as a string, I noticed it because I got a JSON parse error while looking for antarctica
, and it's also not translated:
https://github.com/chubin/wttr.in/blob/e0cc061a64ba86cda1380f0409203a0fb8ae889c/lib/view/line.py#L349-L356
Query
❯ curl -v "wttr.in/antarctica?format=j1&lang=es"
* Trying 5.9.243.187...
* TCP_NODELAY set
* Connected to wttr.in (5.9.243.187) port 80 (#0)
> GET /antarctica?format=j1&lang=es HTTP/1.1
> Host: wttr.in
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.10.3
< Date: Sun, 21 Mar 2021 10:58:19 GMT
< Content-Type: application/json
< Content-Length: 50
< Connection: keep-alive
< Access-Control-Allow-Origin: *
<
Unknown location; please try ~-82.1081821,34.37824* Connection #0 to host wttr.in left intact
(As a side note, could this be also changed so it doesn't return 200 OK
?)
Might be related to the outage as mentioned in https://github.com/chubin/wttr.in/issues/593
Providing the coordinates seems to give a different type of error:
> curl -v "wttr.in/~-82.1081821,34.37824?format=j1"
* Trying 5.9.243.187:80...
* Connected to wttr.in (5.9.243.187) port 80 (#0)
> GET /~-82.1081821,34.37824?format=j1 HTTP/1.1
> Host: wttr.in
> User-Agent: curl/7.75.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Server: nginx/1.10.3
< Date: Sun, 28 Mar 2021 12:50:50 GMT
< Content-Type: application/json
< Content-Length: 39
< Connection: keep-alive
< Access-Control-Allow-Origin: *
<
* Connection #0 to host wttr.in left intact
Unknown location; please try ~not found
Might be related to the outage as mentioned in #593
This issue is 7 days old, and other places (e.g. Madrid) were working fine, so no, it was not affected by an outage.
The problem with the language is clear; what about format? Should it be formatted as HTML, or the standard 404 response should be returned in this case?
Like this:
http://wttr.in/sfddsgfdsgdsd
(the problem with the location resolution was triggered by the outage indeed, by the way)
what about format?
Since I'm requesting with format=j1
, it should be formatted as JSON.
(the problem with the location resolution was triggered by the outage indeed, by the way)
This one isn't caused by the outage, https://wttr.in/antarctica?format=j1&lang=es still returns unknown location.
Something like this?
{
"error": "Unknown location"
}
This one isn't caused by the outage
Yes. And besides that, in this particular case the error message is wrong. The real error was that it could not find data for this location, and the location itself was resolved properly.
By the way, if you need just some location in Antarctica, you can use the Vostok Station for the query:
$ curl wttr.in/Vostok+Station
Weather report: Vostok+Station
Overcast
.--. -54 °C
.-( ). ↗ 23 km/h
(___.__)__) 10 km
0.0 mm
┌─────────────┐
┌──────────────────────────────┬───────────────────────┤ Sun 04 Apr ├───────────────────────┬──────────────────────────────┐
│ Morning │ Noon └──────┬──────┘ Evening │ Night │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│ Overcast │ Overcast │ Overcast │ Overcast │
│ .--. -50(-70) °C │ .--. -51(-71) °C │ .--. -52 °C │ .--. -58 °C │
│ .-( ). ↗ 23-48 km/h │ .-( ). ↗ 24-51 km/h │ .-( ). ↗ 23-49 km/h │ .-( ). ↗ 22-47 km/h │
│ (___.__)__) 10 km │ (___.__)__) 10 km │ (___.__)__) 10 km │ (___.__)__) 10 km │
│ 0.0 mm | 0% │ 0.0 mm | 0% │ 0.0 mm | 0% │ 0.0 mm | 0% │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
┌─────────────┐
┌──────────────────────────────┬───────────────────────┤ Mon 05 Apr ├───────────────────────┬──────────────────────────────┐
│ Morning │ Noon └──────┬──────┘ Evening │ Night │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│ Overcast │ Overcast │ Overcast │ Overcast │
│ .--. -51(-70) °C │ .--. -53(-72) °C │ .--. -55(-75) °C │ .--. -56(-75) °C │
│ .-( ). ↗ 21-44 km/h │ .-( ). ↗ 21-43 km/h │ .-( ). ↗ 19-40 km/h │ .-( ). ↗ 18-38 km/h │
│ (___.__)__) 10 km │ (___.__)__) 10 km │ (___.__)__) 10 km │ (___.__)__) 10 km │
│ 0.0 mm | 0% │ 0.0 mm | 0% │ 0.0 mm | 0% │ 0.0 mm | 0% │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
┌─────────────┐
┌──────────────────────────────┬───────────────────────┤ Tue 06 Apr ├───────────────────────┬──────────────────────────────┐
│ Morning │ Noon └──────┬──────┘ Evening │ Night │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│ Overcast │ Overcast │ Overcast │ Overcast │
│ .--. -60(-77) °C │ .--. -60(-78) °C │ .--. -61 °C │ .--. -66 °C │
│ .-( ). ↗ 13-28 km/h │ .-( ). ↗ 15-32 km/h │ .-( ). → 16-33 km/h │ .-( ). → 15-32 km/h │
│ (___.__)__) 10 km │ (___.__)__) 10 km │ (___.__)__) 10 km │ (___.__)__) 10 km │
│ 0.0 mm | 0% │ 0.0 mm | 0% │ 0.0 mm | 0% │ 0.0 mm | 0% │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘
Location: Vostok Station, станция Восток, AAT, Antarctica [-78.4642714,106.8364678]
Something like this?
{ "error": "Unknown location" }
That's right.
This one isn't caused by the outage
Yes. And besides that, in this particular case the error message is wrong. The real error was that it could not find data for this location, and the location itself was resolved properly.
Ah, makes sense 👍🏼