Opened 6 months ago
Closed 6 months ago
#35538 closed Bug (needsinfo)
GeometryFilter Causes GDALException
Reported by: | Dustin Sampson | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | 3.2 |
Severity: | Normal | Keywords: | |
Cc: | Dustin Sampson | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Description
When using a GeometryFilter
in one of my FilterSets
, passing a valid GeoJSON FeatureCollection
or an invalid JSON object (e.g., {"a": 1}
) results in a 500 error with the message Invalid geometry pointer returned from "OGR_G_CreateGeometryFromJson"
instead of a user-friendly "Invalid geometry value" error.
Steps to Reproduce
- Implement a
GeometryFilter
in aFilterSet
. - Pass a valid GeoJSON
FeatureCollection
or an invalid JSON object ({"a": 1}
) to the filter. - Observe the 500 error with the message:
Invalid geometry pointer returned from "OGR_G_CreateGeometryFromJson"
.
Expected Behavior
The system should raise a ValidationError
with a user-friendly message, such as "Invalid geometry value," instead of causing a 500 server error.
Actual Behavior
A 500 server error occurs with the message: Invalid geometry pointer returned from "OGR_G_CreateGeometryFromJson"
.
Suggested Fix
Modify the to_python
method to include GDALException
in the except block when converting the value to a GEOSGeometry
. This will catch the exception and raise a ValidationError
instead.
Environment
Django==3.2.20
djangorestframework-gis==1.0
djangorestframework==3.13.1
djangorestframework-gis==1.0
Python 3.10.14
GDAL 3.2.2, released 2021/03/05
Attachments (1)
Change History (2)
by , 6 months ago
Attachment: | gdal_exception.patch added |
---|
comment:1 by , 6 months ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Hello! Thank you for this report. Given that Django 3.2 is no longer supported, could you please help us by checking if this issue exists in the latest Django version?