﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35538	GeometryFilter Causes GDALException	Dustin Sampson	nobody	"**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**

1. Implement a `GeometryFilter` in a `FilterSet`.
2. Pass a valid GeoJSON `FeatureCollection` or an invalid JSON object (`{""a"": 1}`) to the filter.
3. 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
"	Bug	closed	GIS	3.2	Normal	needsinfo		Dustin Sampson	Unreviewed	1	0	0	0	0	0
