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

empty notes list crashes api #137

Closed
matkoniecz opened this issue Jan 17, 2023 · 1 comment · Fixed by #138
Closed

empty notes list crashes api #137

matkoniecz opened this issue Jan 17, 2023 · 1 comment · Fixed by #138

Comments

@matkoniecz
Copy link
Contributor

matkoniecz commented Jan 17, 2023

import osmapi
api = osmapi.OsmApi()
print(api.NotesGet(-93.8472901, 35.9763601, -80, 36.176360100000004, limit=1, closed=0))
print(api.NotesGet(-93.8472901, 35.9763601, -93.6472901, 36.176360100000004, limit=1, closed=0))

results in

[{'lon': -80.33461, 'lat': 36.0379985, 'id': '3506423', 'status': 'open', 'date_created': datetime.datetime(2023, 1, 6, 3, 4, 9), 'date_closed': None, 'comments': [{'date': datetime.datetime(2023, 1, 6, 3, 4, 9), 'action': 'opened', 'text': '1760 jonestown Rd\nBusiness office, Triad Semiconductor\n\nvia StreetComplete 50.1', 'html': '<p>1760 jonestown Rd\n<br />Business office, Triad Semiconductor</p>\n\n<p>via StreetComplete 50.1</p>', 'uid': '18189196', 'user': 'Scollywoggle'}]}]
Traceback (most recent call last):
  File "/home/mateusz/.local/lib/python3.8/site-packages/osmapi/OsmApi.py", line 2076, in _OsmResponseToDom
    first_element = all_data[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    print(api.NotesGet(-93.8472901, 35.9763601, -93.6472901, 36.176360100000004, limit=1, closed=0))
  File "/home/mateusz/.local/lib/python3.8/site-packages/osmapi/OsmApi.py", line 1599, in NotesGet
    return self.ParseNotes(data)
  File "/home/mateusz/.local/lib/python3.8/site-packages/osmapi/OsmApi.py", line 1841, in ParseNotes
    noteElements = self._OsmResponseToDom(data, tag="note")
  File "/home/mateusz/.local/lib/python3.8/site-packages/osmapi/OsmApi.py", line 2078, in _OsmResponseToDom
    raise XmlResponseInvalidError(
osmapi.OsmApi.XmlResponseInvalidError: The XML response from the OSM API is invalid: IndexError('list index out of range')

note that the first call worked - because it had some notes to return

@metaodi
Copy link
Owner

metaodi commented Jan 17, 2023

Thanks for this excellent report.
This should be a test case, so this never happens again.

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

Successfully merging a pull request may close this issue.

2 participants