Skip to content

fix: handle empty geometry in GeoJSON models (#176) - #208

Open
sweabhay07 wants to merge 2 commits into
mapillary:mainfrom
sweabhay07:fix/empty-geometry-keyerror
Open

sweabhay07 wants to merge 2 commits into
mapillary:mainfrom
sweabhay07:fix/empty-geometry-keyerror

Conversation

@sweabhay07

Copy link
Copy Markdown

Fixes #176

  • Guarded Geometry.__init__ against empty ({}) or None geometry so it sets type and coordinates to None instead of raising KeyError: 'type'.
  • Handled empty geometry safely in Geometry.to_dict, Feature.__init__, and Feature.to_dict.
  • Verified existing unit tests pass (pytest).

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 6, 2026
@Rubix982

Rubix982 commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

@sweabhay07, please introduce test methods to replicate the issue mentioned in the ticket as well so that can confidently merge for this.

@sweabhay07

Copy link
Copy Markdown
Author

@Rubix982 Added unit tests in tests/models/test_geojson.py covering empty ({}) and None geometries across Geometry, Feature, and GeoJSON models to replicate and verify #176. All 21 tests pass locally with pytest.

@Rubix982

Rubix982 commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

@Rubix982 Added unit tests in tests/models/test_geojson.py covering empty ({}) and None geometries across Geometry, Feature, and GeoJSON models to replicate and verify #176. All 21 tests pass locally with pytest.

Thanks, @sweabhay07 .I cannot merge, but I have approved.

@caglarpir , can we check this please. Thank you.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] Detections with map feature ID decoding error

2 participants