weaviate/weaviate · error

invalid latitude: %w

Error message

invalid latitude: %w

What it means

Same mechanism as the longitude case: the 'latitude' value is run through parseCoordinate, and if it cannot be interpreted as a float (e.g. a string), the error is wrapped as 'invalid latitude: ...'. Both coordinates must be numeric JSON values for the geoCoordinates property to validate.

Source

Thrown at usecases/objects/validation/properties_validation.go:509

	lon, ok := inputMap["longitude"]
	if !ok {
		return nil, fmt.Errorf("geoCoordinates is missing required field 'longitude'")
	}

	lat, ok := inputMap["latitude"]
	if !ok {
		return nil, fmt.Errorf("geoCoordinates is missing required field 'latitude'")
	}

	lonFloat, err := parseCoordinate(lon)
	if err != nil {
		return nil, fmt.Errorf("invalid longitude: %w", err)
	}

	latFloat, err := parseCoordinate(lat)
	if err != nil {
		return nil, fmt.Errorf("invalid latitude: %w", err)
	}

	return &models.GeoCoordinates{
		Longitude: ptFloat32(float32(lonFloat)),
		Latitude:  ptFloat32(float32(latFloat)),
	}, nil
}

func ptFloat32(in float32) *float32 {
	return &in
}

func phoneNumber(data interface{}) (*models.PhoneNumber, error) {
	dataMap, ok := data.(map[string]interface{})
	if !ok {
		return nil, fmt.Errorf("phoneNumber must be a map, but got: %T", data)
	}

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Send latitude as an unquoted JSON number: {"latitude": 52.5} not {"latitude": "52.5"}.
  2. Normalize decimal commas to dots and parse to float in the ETL step before submission.
  3. Verify latitude is within valid range (-90 to 90).
  4. Inspect the wrapped cause after 'invalid latitude:' to identify the exact offending value type.

Example fix

// before
{"location": {"latitude": "52.5", "longitude": 13.4}}
// after
{"location": {"latitude": 52.5, "longitude": 13.4}}
Defensive patterns

Strategy: validation

Validate before calling

function validateLatitude(v) {
  const n = typeof v === 'string' ? Number(v.replace(',', '.')) : v;
  if (typeof n !== 'number' || Number.isNaN(n) || n < -90 || n > 90) {
    throw new Error(`invalid latitude value: ${JSON.stringify(v)}`);
  }
}

Type guard

const isNumeric = (v) => typeof v === 'number' || (typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v)));

Prevention

When it happens

Trigger: geoCoordinates latitude sent as a string ("52.5"), boolean, null, or object — e.g. {"latitude": "52.5", "longitude": 13.4} — during POST /v1/objects, PATCH, or batch import.

Common situations: Spreadsheet/CSV exports where latitude arrives as text; clients from regions where decimal commas produce strings like "52,5"; serialization frameworks that convert numbers to strings.

Related errors


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