2
2
Fork
You've already forked overpass-api-python-wrapper
2

JSONDecodeError when dispatcher responds with duplicate_query error #172

Closed
opened 2024年11月02日 13:15:33 +01:00 by mbugert · 1 comment
mbugert commented 2024年11月02日 13:15:33 +01:00 (Migrated from github.com)
Copy link

Hi there,

Since around March this year [1], Overpass API refuses to handle duplicate queries originating from the same IP within a short time span.

In that case, the content type of the response is text/html; charset=utf-8, with content

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" lang="en"/>
 <title>OSM3S Response</title>
</head>
<body>
<p>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</p>
<p><strong style="color:#FF0000">Error</strong>: runtime error: open64: 0 Success /osm3s_osm_base Dispatcher_Client::request_read_and_idx::duplicate_query </p>
</body>
</html>

API.get() does not check for text/html and tries to parse the response as JSON, which fails:

Traceback (most recent call last):
 File "/home/mbugert/.../playground.py", line 326, in <module>
 plot()
 File "/home/mbugert/.../playground.py", line 305, in plot
 rep = api.get(overpass_query, verbosity="geom")
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/mbugert/.local/bin/pyenv/versions/3.11/lib/python3.11/site-packages/overpass/api.py", line 114, in get
 response = json.loads(r.text)
 ^^^^^^^^^^^^^^^^^^
 File "/home/mbugert/.local/bin/pyenv/versions/3.11.10/lib/python3.11/json/__init__.py", line 346, in loads
 return _default_decoder.decode(s)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/mbugert/.local/bin/pyenv/versions/3.11.10/lib/python3.11/json/decoder.py", line 337, in decode
 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/mbugert/.local/bin/pyenv/versions/3.11.10/lib/python3.11/json/decoder.py", line 355, in raw_decode
 raise JSONDecodeError("Expecting value", s, err.value) from None

This is on python 3.11 with overpass==0.7.2.

Hi there, Since around March this year [[1]](https://github.com/OpenHistoricalMap/issues/issues/718#issuecomment-2014462587), Overpass API refuses to handle duplicate queries originating from the same IP within a short time span. In that case, the content type of the response is `text/html; charset=utf-8`, with content ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" lang="en"/> <title>OSM3S Response</title> </head> <body> <p>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</p> <p><strong style="color:#FF0000">Error</strong>: runtime error: open64: 0 Success /osm3s_osm_base Dispatcher_Client::request_read_and_idx::duplicate_query </p> </body> </html> ``` `API.get()` does not check for `text/html` and tries to parse the response as JSON, which fails: ``` Traceback (most recent call last): File "/home/mbugert/.../playground.py", line 326, in <module> plot() File "/home/mbugert/.../playground.py", line 305, in plot rep = api.get(overpass_query, verbosity="geom") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mbugert/.local/bin/pyenv/versions/3.11/lib/python3.11/site-packages/overpass/api.py", line 114, in get response = json.loads(r.text) ^^^^^^^^^^^^^^^^^^ File "/home/mbugert/.local/bin/pyenv/versions/3.11.10/lib/python3.11/json/__init__.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mbugert/.local/bin/pyenv/versions/3.11.10/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/mbugert/.local/bin/pyenv/versions/3.11.10/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None ``` This is on python 3.11 with `overpass==0.7.2`.

Thanks for the report. If you can share a minimal reproducer and the raw Overpass response that triggers duplicate_query, we can add a test and fix in 0.8.

Thanks for the report. If you can share a minimal reproducer and the raw Overpass response that triggers duplicate_query, we can add a test and fix in 0.8.
Sign in to join this conversation.
No Branch/Tag specified
main
tutorial/d1-httpx-nvim
0.8.x
dev-contributor-tooling
1.0-dev
dev
feature/api-modernization
maintenance/base-0.8
maintenance/geojson-fixtures
archive/async-models
maintenance/endpoint-guard
maintenance/live-query-tool
maintenance/modernize-plan
archive/dev-prebaseline-20260502
archive/modernize
archive/chore-tests
chore/poetry
archive/readme
v0.8.2
v0.8.1
v0.8.0
v0.7.2
0.7.1
0.7.0
0.6.1
0.6.0
0.5.7
0.5.6
0.5.5
0.4.0
0.1.0
0.0.2
0.0.1
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mvexel/overpass-api-python-wrapper#172
Reference in a new issue
mvexel/overpass-api-python-wrapper
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?