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

In a weird case, don't fail utterly, but add an error message #1452

Draft
wants to merge 3 commits into
base: maint-1.10
Choose a base branch
from

Conversation

sgillies
Copy link
Member

@sgillies sgillies commented Sep 22, 2024

Follow up on #1451.

GeoJSON feature properties are not tightly constrained. GDAL/OGR depends on constraints, and would prefer a single type for field values. When GDAL receives features where a named property (or field) may be a string, or a number, or something else, the behavior is not well defined. In versions before 3.6, it seems like GDAL interpreted these as String type fields. After, it seems that these are interpreted as String(JSON) fields.

When GDAL has determined that the field is type: String(JSON) (rightly or wrongly), if a JSONDecodeError occurs, instead of raising an exception and bringing processing to a halt, we might return a error message in place of a normal value.

I honestly have no idea what the best UX is here, I don't see obvious precedent yet.

@sgillies sgillies self-assigned this Sep 22, 2024
try:
return json.loads(val)
except json.JSONDecodeError as error:
return f"String(JSON) field could not be decoded: {val=}, {error=}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwtoews would it be weird to have an error message show up in GeoPandas as a feature property? What does pyogrio do when a single feature property can't be imported correctly?

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.

1 participant