{"record":{"id":"eda0d59f2f2df1af","repo":"weaviate/weaviate","slug":"valuegeorange-field-distance-max-must-be-a-posi","errorCode":null,"errorMessage":"valueGeoRange: field 'distance.max' must be a positive number","messagePattern":"valueGeoRange: field 'distance\\.max' must be a positive number","errorType":"validation","errorClass":null,"httpStatus":422,"severity":"error","filePath":"adapters/handlers/rest/filterext/parse_value.go","lineNumber":150,"sourceCode":"\t\tif len(in.ValueBooleanArray) == 0 {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\treturn valueFilter(in.ValueBooleanArray, schema.DataTypeBoolean), nil\n\t},\n\n\t// geo range\n\tfunc(in *models.WhereFilter) (*filters.Value, error) {\n\t\tif in.ValueGeoRange == nil {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tif in.ValueGeoRange.Distance == nil {\n\t\t\treturn nil, fmt.Errorf(\"valueGeoRange: field 'distance' must be set\")\n\t\t}\n\n\t\tif in.ValueGeoRange.Distance.Max < 0 {\n\t\t\treturn nil, fmt.Errorf(\"valueGeoRange: field 'distance.max' must be a positive number\")\n\t\t}\n\n\t\tif in.ValueGeoRange.GeoCoordinates == nil {\n\t\t\treturn nil, fmt.Errorf(\"valueGeoRange: field 'geoCoordinates' must be set\")\n\t\t}\n\n\t\treturn valueFilter(filters.GeoRange{\n\t\t\tDistance: float32(in.ValueGeoRange.Distance.Max),\n\t\t\tGeoCoordinates: &models.GeoCoordinates{\n\t\t\t\tLatitude:  in.ValueGeoRange.GeoCoordinates.Latitude,\n\t\t\t\tLongitude: in.ValueGeoRange.GeoCoordinates.Longitude,\n\t\t\t},\n\t\t}, schema.DataTypeGeoCoordinates), nil\n\t},\n\t// deprecated string\n\tfunc(in *models.WhereFilter) (*filters.Value, error) {\n\t\tif in.ValueString == nil {\n\t\t\treturn nil, nil","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/handlers/rest/filterext/parse_value.go#L132-L168","documentation":"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.","triggerScenarios":"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).","commonSituations":"Computing radius in code that can produce negatives (km-to-meters conversion with bad input); user-supplied radius values passed through without clamping.","solutions":["Ensure distance.max is >= 0 before sending; clamp with Math.max(0, radius)","Validate user-supplied radius input at the UI/API boundary","Check unit conversion math producing the radius"],"exampleFix":"// before\nmaxDistance: km * 1000 - offset // can go negative\n// after\nmaxDistance: Math.max(0, km * 1000 - offset)","handlingStrategy":"validation","validationCode":"function validateGeoDistance(g) {\n  if (g.distance.max < 0) throw new Error('distance.max must be >= 0, got ' + g.distance.max);\n}","typeGuard":"function hasPositiveDistance(g) { return typeof g?.distance?.max === 'number' && g.distance.max >= 0; }","tryCatchPattern":"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; }","preventionTips":["Clamp computed radii with Math.max(0, r)","Validate user-supplied radius inputs before sending","Check unit conversions (km vs m) for sign/negativity bugs"],"tags":["geo","validation","filter"],"backgroundTag":"invalid-argument-value","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}