weaviate/weaviate · error

valueGeoRange: field 'distance' must be set

Error message

valueGeoRange: field 'distance' must be set

What it means

Validation error in the geo-range branch of filterext's where-filter value parser: a ValueGeoRange was supplied with a distance object whose Distance field is nil. The distance (max) is mandatory for WithinGeoRange semantics, so the filter is rejected before it reaches the filter compiler.

Source

Thrown at adapters/handlers/rest/filterext/parse_value.go:146

		return valueFilter(in.ValueDateArray, schema.DataTypeDate), nil
	},
	// boolean
	func(in *models.WhereFilter) (*filters.Value, error) {
		if len(in.ValueBooleanArray) == 0 {
			return nil, nil
		}

		return valueFilter(in.ValueBooleanArray, schema.DataTypeBoolean), nil
	},

	// geo range
	func(in *models.WhereFilter) (*filters.Value, error) {
		if in.ValueGeoRange == nil {
			return nil, nil
		}

		if in.ValueGeoRange.Distance == nil {
			return nil, fmt.Errorf("valueGeoRange: field 'distance' must be set")
		}

		if in.ValueGeoRange.Distance.Max < 0 {
			return nil, fmt.Errorf("valueGeoRange: field 'distance.max' must be a positive number")
		}

		if in.ValueGeoRange.GeoCoordinates == nil {
			return nil, fmt.Errorf("valueGeoRange: field 'geoCoordinates' must be set")
		}

		return valueFilter(filters.GeoRange{
			Distance: float32(in.ValueGeoRange.Distance.Max),
			GeoCoordinates: &models.GeoCoordinates{
				Latitude:  in.ValueGeoRange.GeoCoordinates.Latitude,
				Longitude: in.ValueGeoRange.GeoCoordinates.Longitude,
			},
		}, schema.DataTypeGeoCoordinates), nil
	},

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Add the distance object: valueGeoRange: {distance: {max: 2000}, geoCoordinates: {latitude: 51.5, longitude: -0.09}}
  2. Use the SDK's GeoRange/GeoCoordinates helper types so required nested fields are enforced
  3. Validate the payload structure client-side before sending

Example fix

// before
"valueGeoRange": {"geoCoordinates": {"latitude": 51.5, "longitude": -0.09}}
// after
"valueGeoRange": {"geoCoordinates": {"latitude": 51.5, "longitude": -0.09}, "distance": {"max": 2000}}
Defensive patterns

Strategy: validation

Validate before calling

function validateGeoRange(g) {
  if (!g.distance || typeof g.distance.max !== 'number') throw new Error('valueGeoRange.distance.max is required');
}

Type guard

function hasDistance(g) { return g != null && typeof g.distance === 'object' && g.distance !== null && typeof g.distance.max === 'number'; }

Try / catch

try { await queryWithGeo(g); } catch (e) { if (/field 'distance' must be set/.test(e.message)) console.error('Add distance: {max: <meters>} to valueGeoRange'); else throw e; }

Prevention

When it happens

Trigger: A nearText/nearObject-style where geoRange filter sent as {valueGeoRange: {geoCoordinates: {...}}} without the distance object, or with distance misspelled.

Common situations: Clients building GeoRange payloads manually instead of via SDK helpers; API version differences where older clients used a flat latitude/longitude/number shape.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/d74e0a9f09764f70. Report an issue: GitHub.