Skip to content

Fix geojson_source_to_csv crash on non-uniform feature properties - #108

Merged
iandees merged 1 commit into
masterfrom
issue-106-geojson-nonuniform-properties
Aug 22, 2026
Merged

Fix geojson_source_to_csv crash on non-uniform feature properties#108
iandees merged 1 commit into
masterfrom
issue-106-geojson-nonuniform-properties

Conversation

@iandees

@iandees iandees commented Aug 22, 2026

Copy link
Copy Markdown
Member

Summary

  • geojson_source_to_csv() picked its output CSV columns from the first feature's properties only, then crashed with ValueError: dict contains fields not in fieldnames as soon as a later feature had a property key the first feature didn't have.
  • Whether it crashed was order-dependent on which feature came first in the file.
  • Fixed by making a first pass over the file to collect the union of every feature's property keys (in first-seen order), then a second pass to write rows against that fixed set of fieldnames. Missing keys on a given feature fall back to DictWriter's default restval=''.

Fixes #106

Test plan

  • Added test_geojson_source_to_csv_non_uniform_properties, reproducing the crash with two features that have different property keys
  • docker run --rm -v "$(pwd)":/usr/local/src/batch-machine -w /usr/local/src/batch-machine batch-machine-test:latest python3 -m unittest openaddr.tests.conform -v — all 65 tests pass

@iandees
iandees merged commit 2fe1e2c into master Aug 22, 2026
1 check passed
@iandees
iandees deleted the issue-106-geojson-nonuniform-properties branch August 22, 2026 05:52
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 this pull request may close these issues.

geojson_source_to_csv crashes on GeoJSON sources where features have different property keys

1 participant