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

SimpleWriter.add_node can write invalid nodes on error #212

Closed
morandd opened this issue Oct 4, 2022 · 0 comments · Fixed by #213
Closed

SimpleWriter.add_node can write invalid nodes on error #212

morandd opened this issue Oct 4, 2022 · 0 comments · Fixed by #213

Comments

@morandd
Copy link

morandd commented Oct 4, 2022

Hard to replicate this, but it seems that if SimpleWriter.add_node fails due to a Python->C++ typecasting error, it will still write an invalid node to the output. The output files seem to contain multiple nodes with id=0 and no tags at the same lines where I encounter casting errors.

so:

try 
    writer.add_node(oo)
catch
# error message like this:
RuntimeError: Unable to cast Python instance to C++ type (#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)
{'GgCO2': '0.6217761361811466', 't': 'other', 'addr:constituency': 'Madevu', 'addr:ward': 'Mtendere Ward 30', 'amenity': 'waste_disposal'}

seems to write an incomplete node to the output file.

This is problematic because the incomplete node has ID=0, and if there are multiple cases this introduces duplicate nodes with id=0.

Hopefully this is an easy fix to simply not write anything to the file in case of an error during the Python->C++ typecasting for tags?

lonvia added a commit to lonvia/pyosmium that referenced this issue Oct 24, 2022
If an exception was caught on the Python side, then the item that
caused the exception would remain in the buffer and be written out
with the next valid item.

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

Successfully merging a pull request may close this issue.

1 participant