Skip to content

SimpleWriter.add_node can write invalid nodes on error #212

@morandd

Description

@morandd

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions