actualbudget/actual · error · Error
Invalid maxDistance: must be a finite positive number greate
Error message
Invalid maxDistance: must be a finite positive number greater than 0
What it means
Error thrown by getNearbyPayees when maxDistance is not a finite number greater than 0. The proximity query needs a positive search radius to bound its results.
Source
Thrown at packages/loot-core/src/server/payees/app.ts:245
latitude: number;
longitude: number;
maxDistance?: number;
}): Promise<NearbyPayeeEntity[]> {
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',
);
}
if (!Number.isFinite(maxDistance) || maxDistance <= 0) {
throw new Error(
'Invalid maxDistance: must be a finite positive number greater than 0',
);
}
// Get the closest location for each payee within maxDistance using window functions
const query = `
WITH payee_distances AS (
SELECT
pl.id as location_id,
pl.payee_id,
pl.latitude,
pl.longitude,
pl.created_at,
p.id,
p.name,
p.transfer_acct,
p.favorite,
p.learn_categories,View on GitHub (pinned to d4334cb6e6)
Solutions
- Pass a finite positive maxDistance (e.g. distance in meters/km per the API's unit)
- Default the value when undefined: maxDistance ?? 1000
- Guard against 0/negative values from UI inputs before calling
- Check unit conversion (km to m, miles to m) for sign and scale errors
Example fix
// before
await app.getNearbyPayees(lat, lon, radiusInput); // may be '' or 0
// after
const dist = Number(radiusInput);
if (Number.isFinite(dist) && dist > 0) {
await app.getNearbyPayees(lat, lon, dist);
} Defensive patterns
Strategy: validation
Validate before calling
const d = Number(userDistance); if (Number.isFinite(d) && d > 0) await app.getNearbyPayees(lat, lon, d);
Try / catch
try {
return await app.getNearbyPayees(lat, lon, dist);
} catch (e) {
if (String(e.message).includes('maxDistance')) return await app.getNearbyPayees(lat, lon, 1000);
throw e;
} Prevention
- Clamp distance inputs to a positive range
- Set explicit defaults for optional params
- Verify unit conversions
- Treat empty inputs as undefined, not 0
When it happens
Trigger: Calling getNearbyPayees with maxDistance = 0, negative values, NaN, Infinity, or undefined.
Common situations: UI slider defaulting to 0, distance in wrong units causing negative values after conversion, config value missing so variable is undefined, user clearing an input field.
Related errors
- Invalid coordinates: latitude must be between -90 and 90, lo
- 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/5c06eba2e476022f.
Report an issue: GitHub.