mastra-ai/mastra · error
Location '${inputData.city}' not found
Error message
Location '${inputData.city}' not found What it means
The weather tool queries the open-meteo geocoding API to convert the user-supplied city into latitude/longitude. If the API responds without a first result (results[0] undefined), the tool throws "Location '<city>' not found". This is an external-API lookup miss, not a code bug: the city string did not resolve in the geocoding service.
Source
Thrown at packages/agent-builder/src/defaults.ts:294
id: 'fetch-weather',
description: 'Fetches weather forecast for a given city',
inputSchema: z.object({
city: z.string().describe('The city to get the weather for'),
}),
outputSchema: forecastSchema,
execute: async (inputData) => {
if (!inputData) {
throw new Error('Input data not found');
}
const geocodingUrl = \`https://geocoding-api.open-meteo.com/v1/search?name=\${encodeURIComponent(inputData.city)}&count=1\`;
const geocodingResponse = await fetch(geocodingUrl);
const geocodingData = (await geocodingResponse.json()) as {
results: { latitude: number; longitude: number; name: string }[];
};
if (!geocodingData.results?.[0]) {
throw new Error(\`Location '\${inputData.city}' not found\`);
}
const { latitude, longitude, name } = geocodingData.results[0];
const weatherUrl = \`https://api.open-meteo.com/v1/forecast?latitude=\${latitude}&longitude=\${longitude}¤t=precipitation,weathercode&timezone=auto,&hourly=precipitation_probability,temperature_2m\`
const response = await fetch(weatherUrl);
const data = (await response.json()) as {
current: {
time: string;
precipitation: number;
weathercode: number;
};
hourly: {
precipitation_probability: number[];
temperature_2m: number[];
};
};
View on GitHub (pinned to 75dd419e61)
Solutions
- Retry with a correctly spelled, well-known city name (e.g. 'London', 'Paris')
- Normalize/validate the city string before passing it to the tool
- Check that the geocoding API is reachable (curl the search URL manually) and not returning an error body
- Handle the throw in the surrounding workflow/agent turn and ask the user for a valid location
Example fix
// before
const data = await mastra.getWorkflow('weatherWorkflow').start({ triggerData: { city: 'San Fransisco' } });
// after
const data = await mastra.getWorkflow('weatherWorkflow').start({ triggerData: { city: 'San Francisco' } }); Defensive patterns
Strategy: try-catch
Validate before calling
const url = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(city)}&count=1`;
const preview = await fetch(url).then(r => r.json());
if (!preview?.results?.length) throw new Error(`'${city}' is not geocodable; pick a known city`); Try / catch
try {
await mastra.getWorkflow('weatherWorkflow').start({ triggerData: { city } });
} catch (e) {
if (e instanceof Error && e.message.includes('not found')) {
// prompt user for a valid city
} else throw e;
} Prevention
- Validate/normalize city names before invoking the tool
- Constrain agent prompts to real, well-known locations
- Pre-flight the geocoding API in health checks if the feature is user-facing
When it happens
Trigger: Calling the default weather workflow/tool with a city that open-meteo's geocoding API cannot resolve — misspelled names, non-city strings, cities in unsupported scripts, or empty results from https://geocoding-api.open-meteo.com/v1/search.
Common situations: Test agents asking for fictional places ('Atlantis', 'My House'); typos like 'San Fransisco'; user input in a language/script geocoding doesn't index; network degradation returning a non-error JSON body without results.
Related errors
- Failed to fetch Mastra templates: ${error instanceof Error ?
- Location '${location}' not found
- Token exchange failed: ${error}
- Failed to fetch user info from Auth0
- Token exchange failed: ${error}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/606f9cfcca9fdb52.
Report an issue: GitHub.