Freika/dawarich · warning

[FamilyLayer] Skipping member update with invalid coordinate

Error message

[FamilyLayer] Skipping member update with invalid coordinates:

What it means

FamilyLayer.updateMember coerces member.longitude/latitude with Number() and rejects the update when _isValidCoord fails (non-finite or out-of-range values). The warn logs the whole member object, meaning the family-locations payload contained a member whose coordinates are null, undefined, non-numeric strings, or outside valid lon/lat ranges. That member's marker is skipped, others still render.

Source

Thrown at app/javascript/maps_maplibre/layers/family_layer.js:196

      this.id,
      `${this.id}-labels`,
      `${this.id}-pulse`,
      `${this.id}-history`,
    ]
  }

  /**
   * Update single family member location
   * @param {Object} member - { id, name, latitude, longitude, color }
   */
  updateMember(member) {
    const features = this.data?.features || []
    const memberId = member.user_id || member.id
    const lon = Number(member.longitude)
    const lat = Number(member.latitude)

    if (!this._isValidCoord(lon, lat)) {
      console.warn(
        "[FamilyLayer] Skipping member update with invalid coordinates:",
        member,
      )
      return
    }

    const coords = [lon, lat]
    const color = member.color || this.getMemberColor(memberId)

    // Find existing or add new
    const index = features.findIndex((f) => f.properties.id === memberId)

    const feature = {
      type: "Feature",
      geometry: {
        type: "Point",
        coordinates: coords,
      },

View on GitHub (pinned to 97fad417c5)

Solutions

  1. Inspect the logged member object to see which field is bad (usually null/undefined latitude or longitude).
  2. Filter non-geocoded members server-side (skip serializing members without coordinates) or in the caller before updateMember is invoked.
  3. If fields were renamed in the API payload, update the destructuring/property reads in family_layer.js to match (longitude/latitude keys).

Example fix

// before
updateMember(member) {
  const lon = Number(member.longitude)
  const lat = Number(member.latitude)
  if (!this._isValidCoord(lon, lat)) { console.warn(...); return }
  ...
}

// after (caller filters first)
const valid = (m) => Number.isFinite(+m.longitude) && Number.isFinite(+m.latitude)
locations.filter(valid).forEach((m) => familyLayer.updateMember(m))
Defensive patterns

Strategy: validation

Validate before calling

const lon = Number(member.longitude)
const lat = Number(member.latitude)
const valid = Number.isFinite(lon) && Number.isFinite(lat) &&
  lon >= -180 && lon <= 180 && lat >= -90 && lat <= 90

Type guard

const hasValidCoords = (m) =>
  Number.isFinite(Number(m?.longitude)) &&
  Number.isFinite(Number(m?.latitude))

Prevention

When it happens

Trigger: A family_location ActionCable broadcast or /api family-locations fetch includes a member with null latitude/longitude (location sharing off, no data yet), string coordinates like "51.1\u00b0N", or swapped/out-of-range values (lat > 90). Number(null) is 0 which may pass, but Number(undefined) is NaN which fails _isValidCoord.

Common situations: A family member disabled location sharing so the backend serializes nulls; new member with no points yet; third-party client uploading malformed coords; API schema change renaming lat/lon fields so both read as undefined.

Related errors


AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21). Data as JSON: /api/errors/7ccb32e66199bd3f. Report an issue: GitHub.