NousResearch/hermes-agent · error
latitude and longitude must be numbers
Error message
latitude and longitude must be numbers
What it means
Thrown by buildLocationPayload in the WhatsApp bridge helpers when latitude/longitude cannot be coerced to finite numbers (Number() yields NaN, undefined, or Infinity). It guards before building the Baileys location message, which requires numeric degreesLatitude/degreesLongitude.
Source
Thrown at scripts/whatsapp-bridge/bridge_helpers.js:177
export function buildTextSendPayload(text, { replyTo, messageStore } = {}) {
const content = { text };
const options = {};
const quoted = messageStore?.get(replyTo);
if (quoted?.key && quoted?.message) {
// Baileys expects quoted messages as sendMessage options, not inside the
// message content payload. Keeping this split avoids silently sending a
// literal/ignored `quoted` field instead of a native WhatsApp reply.
options.quoted = quoted;
}
return { content, options };
}
export function buildLocationPayload({ latitude, longitude, name, address } = {}) {
const lat = Number(latitude);
const lon = Number(longitude);
if (!Number.isFinite(lat) || !Number.isFinite(lon)) {
throw new Error('latitude and longitude must be numbers');
}
if (lat < -90 || lat > 90 || lon < -180 || lon > 180) {
throw new Error('latitude/longitude out of range');
}
const location = {
degreesLatitude: lat,
degreesLongitude: lon,
};
if (name) location.name = String(name);
if (address) location.address = String(address);
return { location };
}
function textFromQuotedMessage(quotedMessage) {
if (!quotedMessage) return '';
if (quotedMessage.conversation) return quotedMessage.conversation;
if (quotedMessage.extendedTextMessage?.text) return quotedMessage.extendedTextMessage.text;View on GitHub (pinned to c896c09c42)
Solutions
- Supply numeric latitude and longitude in the location payload (validate with Number.isFinite first).
- If only a place name is known, geocode it to coordinates before calling the bridge.
- In tool schemas, mark latitude/longitude as required numeric properties so the model cannot omit them.
Example fix
// before
buildLocationPayload({ name: 'Office' })
// after
buildLocationPayload({ latitude: 37.7749, longitude: -122.4194, name: 'Office' }) Defensive patterns
Strategy: validation
Validate before calling
function isValidLatLng(lat: unknown, lon: unknown): boolean {
const a = Number(lat), b = Number(lon)
return Number.isFinite(a) && Number.isFinite(b)
} Type guard
function hasCoordinates(p: { latitude?: unknown; longitude?: unknown }): p is { latitude: number; longitude: number } {
return Number.isFinite(Number(p.latitude)) && Number.isFinite(Number(p.longitude))
} Try / catch
try {
buildLocationPayload(args)
} catch (e) {
if (e instanceof Error && e.message === 'latitude and longitude must be numbers')
reply('Send me numeric latitude and longitude.')
else throw e
} Prevention
- Declare latitude/longitude as required numeric fields in tool schemas (type: number).
- Geocode place names to coordinates before attempting a location send.
- Unit-test the bridge helper with missing/NaN inputs.
When it happens
Trigger: Sending a WhatsApp location message via the bridge with latitude/longitude missing, non-numeric strings ('abc'), null, or empty values in the send-location payload.
Common situations: Agent/tool call omitting lat/lon fields, geocoding step failing upstream and passing undefined through, or sending place name only without coordinates.
Related errors
- latitude/longitude out of range
- question is required
- at least two poll options are required
- Preview mode — launching is disabled.
- no install root
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/ec7a8bd0e9a79fa3.
Report an issue: GitHub.