weaviate/weaviate · error

valueGeoRange: field 'distance.max' must be a positive numbe

Error message

valueGeoRange: field 'distance.max' must be a positive number

What it means

Validation error in the geo-range branch of filterext's value parser: the ValueGeoRange distance object is present but its Max is negative. A geo-distance radius must be a positive number; negative values are rejected rather than absolutized.

Source

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

		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
	},
	// deprecated string
	func(in *models.WhereFilter) (*filters.Value, error) {
		if in.ValueString == nil {
			return nil, nil

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Ensure distance.max is >= 0 before sending; clamp with Math.max(0, radius)
  2. Validate user-supplied radius input at the UI/API boundary
  3. Check unit conversion math producing the radius

Example fix

// before
maxDistance: km * 1000 - offset // can go negative
// after
maxDistance: Math.max(0, km * 1000 - offset)
Defensive patterns

Strategy: validation

Validate before calling

function validateGeoDistance(g) {
  if (g.distance.max < 0) throw new Error('distance.max must be >= 0, got ' + g.distance.max);
}

Type guard

function hasPositiveDistance(g) { return typeof g?.distance?.max === 'number' && g.distance.max >= 0; }

Try / catch

try { await queryWithGeo(g); } catch (e) { if (/distance.max.*positive/.test(e.message)) console.error('Clamp radius: max = Math.max(0, max)'); else throw e; }

Prevention

When it happens

Trigger: Sending valueGeoRange with distance.max < 0, e.g. {distance: {max: -500}}, typically due to a computed variable that went negative (unit conversion bug, subtracting offsets).

Common situations: Computing radius in code that can produce negatives (km-to-meters conversion with bad input); user-supplied radius values passed through without clamping.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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