weaviate/weaviate · error
longitude must be set
Error message
longitude must be set
What it means
The longitude half of the same validation: geoCoordiantesToVector builds the [lat, lon] vector and fails when Longitude is nil even if latitude is present. Both coordinates must be non-nil to produce a usable 2D geo vector.
Source
Thrown at adapters/repos/db/vector/geo/coordinates_for_id.go:64
if err != nil || coordinates == nil {
return nil, err
}
return geoCoordiantesToVector(coordinates)
}
// GeoCoordinatesToVector converts geo coordinates to a vector of [lat, lon].
func GeoCoordinatesToVector(in *models.GeoCoordinates) ([]float32, error) {
return geoCoordiantesToVector(in)
}
func geoCoordiantesToVector(in *models.GeoCoordinates) ([]float32, error) {
if in.Latitude == nil {
return nil, fmt.Errorf("latitude must be set")
}
if in.Longitude == nil {
return nil, fmt.Errorf("longitude must be set")
}
return []float32{*in.Latitude, *in.Longitude}, nil
}
View on GitHub (pinned to 75aa4b6d11)
Solutions
- Set the Longitude field on the GeoCoordinates object before the call
- Validate that both latitude and longitude are present at ingest/query time and reject partial geo values
- Coerce upstream data (e.g. default or reject records) so longitude is never null for geo properties
Example fix
// before
geo := &models.GeoCoordinates{Latitude: &lat}
vec, err := geo.GeoCoordinatesToVector(geo) // error: longitude must be set
// after
geo := &models.GeoCoordinates{Latitude: &lat, Longitude: &lon}
vec, err := geo.GeoCoordinatesToVector(geo) Defensive patterns
Strategy: validation
Validate before calling
func validGeo(g *models.GeoCoordinates) bool {
return g != nil && g.Latitude != nil && g.Longitude != nil
} Type guard
func hasLatLon(g *models.GeoCoordinates) bool {
return g != nil && g.Longitude != nil && g.Latitude != nil
} Try / catch
vec, err := geo.GeoCoordinatesToVector(g)
if err != nil {
return fmt.Errorf("invalid geo input: %w", err)
} Prevention
- Treat longitude as mandatory for all geo properties
- Sanitize upstream data: drop or fix records with null longitude
- Unit-test geo ingestion with partial-coordinate payloads
When it happens
Trigger: Adding or searching geo data where GeoCoordinates contains only latitude — e.g. {"geoCoordinates": {"latitude": 52.36}} passed to an insert or a WithinGeoRange query.
Common situations: Partial geographic data from upstream sources, client forms that make longitude optional, or deserialization dropping the longitude field because it was null in the payload.
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
- latitude must be set
- invalid arguments: GeoCoordinates in range must be set
- distance vectors must have len 2
- unknown datatype for aggregation type reference: ${dataType}
- tempVectorForIDWithViewThunk cannot be nil
AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04).
Data as JSON: /api/errors/036c733fb8e14f4b.
Report an issue: GitHub.