actualbudget/actual · error · Error
Invalid coordinates: latitude must be between -90 and 90, lo
Error message
Invalid coordinates: latitude must be between -90 and 90, longitude must be between -180 and 180
What it means
Generic Error thrown by createPayeeLocation when latitude/longitude are non-finite or outside the valid geographic ranges (lat ±90, lon ±180). Prevents storing physically impossible coordinates for payee locations.
Source
Thrown at packages/loot-core/src/server/payees/app.ts:167
payeeId,
latitude,
longitude,
}: {
payeeId: PayeeEntity['id'];
latitude: number;
longitude: number;
}): Promise<PayeeLocationEntity['id']> {
const created_at = Date.now();
if (
!Number.isFinite(latitude) ||
!Number.isFinite(longitude) ||
latitude < -90 ||
latitude > 90 ||
longitude < -180 ||
longitude > 180
) {
throw new Error(
'Invalid coordinates: latitude must be between -90 and 90, longitude must be between -180 and 180',
);
}
return await db.insertWithUUID('payee_locations', {
payee_id: payeeId,
latitude,
longitude,
created_at,
});
}
async function getPayeeLocations({
payeeId,
}: {
payeeId?: PayeeEntity['id'];
} = {}): Promise<PayeeLocationEntity[]> {
let query = 'SELECT * FROM payee_locations WHERE tombstone IS NOT 1';View on GitHub (pinned to d4334cb6e6)
Solutions
- Validate latitude is a finite number in [-90,90] and longitude in [-180,180] before calling
- Check that lat/lon arguments are not swapped
- Coerce string coordinates with Number() and reject NaN before calling
- Fix upstream geocoding to skip records with missing coordinates
Example fix
// before
await app.createPayeeLocation(payeeId, '37.77', -122.4); // string lat
// after
const lat = Number('37.77');
await app.createPayeeLocation(payeeId, lat, -122.4); Defensive patterns
Strategy: validation
Validate before calling
function isValidCoords(lat, lon) {
return Number.isFinite(lat) && Number.isFinite(lon) &&
lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180;
}
if (!isValidCoords(lat, lon)) return; Try / catch
try {
await app.createPayeeLocation(payeeId, lat, lon);
} catch (e) {
console.warn(`Skipping payee location: ${e.message}`);
} Prevention
- Validate coordinates at the source and skip unknowns
- Keep lat/lon order consistent
- Coerce and check numeric strings before calling
- Reuse one range-check utility everywhere
When it happens
Trigger: Calling createPayeeLocation with latitude outside [-90,90], longitude outside [-180,180], NaN, Infinity, or non-numeric values that pass as NaN/Infinity.
Common situations: Geocoding APIs returning null/NaN, latitude/longitude swapped or in degrees-vs-radians confusion, string inputs not coerced to numbers, importing data with empty coordinate columns.
Related errors
- Invalid maxDistance: must be a finite positive number greate
- Invalid --name: must be a non-empty string.
- No update fields provided. Use --name or --offbudget.
- Invalid cutoff date: expected a valid date (e.g. YYYY-MM-DD)
- No update fields provided. Use --name or --hidden.
AI-assisted analysis of actualbudget/actual@d4334cb6e6 (2026-08-29).
Data as JSON: /api/errors/2e25bb19609372b3.
Report an issue: GitHub.