{"record":{"id":"606f9cfcca9fdb52","repo":"mastra-ai/mastra","slug":"location-inputdata-city-not-found","errorCode":null,"errorMessage":"Location '${inputData.city}' not found","messagePattern":"Location '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent-builder/src/defaults.ts","lineNumber":294,"sourceCode":"  id: 'fetch-weather',\n  description: 'Fetches weather forecast for a given city',\n  inputSchema: z.object({\n    city: z.string().describe('The city to get the weather for'),\n  }),\n  outputSchema: forecastSchema,\n  execute: async (inputData) => {\n    if (!inputData) {\n      throw new Error('Input data not found');\n    }\n\n    const geocodingUrl = \\`https://geocoding-api.open-meteo.com/v1/search?name=\\${encodeURIComponent(inputData.city)}&count=1\\`;\n    const geocodingResponse = await fetch(geocodingUrl);\n    const geocodingData = (await geocodingResponse.json()) as {\n      results: { latitude: number; longitude: number; name: string }[];\n    };\n\n    if (!geocodingData.results?.[0]) {\n      throw new Error(\\`Location '\\${inputData.city}' not found\\`);\n    }\n\n    const { latitude, longitude, name } = geocodingData.results[0];\n\n    const weatherUrl = \\`https://api.open-meteo.com/v1/forecast?latitude=\\${latitude}&longitude=\\${longitude}&current=precipitation,weathercode&timezone=auto,&hourly=precipitation_probability,temperature_2m\\`\n    const response = await fetch(weatherUrl);\n    const data = (await response.json()) as {\n      current: {\n        time: string;\n        precipitation: number;\n        weathercode: number;\n      };\n      hourly: {\n        precipitation_probability: number[];\n        temperature_2m: number[];\n      };\n    };\n","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/agent-builder/src/defaults.ts#L276-L312","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst data = await mastra.getWorkflow('weatherWorkflow').start({ triggerData: { city: 'San Fransisco' } });\n\n// after\nconst data = await mastra.getWorkflow('weatherWorkflow').start({ triggerData: { city: 'San Francisco' } });","handlingStrategy":"try-catch","validationCode":"const url = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(city)}&count=1`;\nconst preview = await fetch(url).then(r => r.json());\nif (!preview?.results?.length) throw new Error(`'${city}' is not geocodable; pick a known city`);","typeGuard":null,"tryCatchPattern":"try {\n  await mastra.getWorkflow('weatherWorkflow').start({ triggerData: { city } });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not found')) {\n    // prompt user for a valid city\n  } else throw e;\n}","preventionTips":["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"],"tags":["network","external-api","geocoding"],"backgroundTag":"location-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}