{"record":{"id":"763c56c931409ddf","repo":"mastra-ai/mastra","slug":"location-location-not-found","errorCode":null,"errorMessage":"Location '${location}' not found","messagePattern":"Location '(.+?)' not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/__fixtures__/tools.ts","lineNumber":41,"sourceCode":"export const weatherTool = createTool({\n  id: 'get-weather',\n  description: 'Get current weather for a location',\n  inputSchema: z.object({\n    location: z.string().describe('City name'),\n  }),\n  execute: async input => {\n    console.info('weather tool', input);\n    return await getWeather(input.location);\n  },\n});\n\nconst getWeather = async (location: string) => {\n  const geocodingUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(location)}&count=1`;\n  const geocodingResponse = await fetch(geocodingUrl);\n  const geocodingData = (await geocodingResponse.json()) as GeocodingResponse;\n\n  if (!geocodingData.results?.[0]) {\n    throw new Error(`Location '${location}' 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=temperature_2m,apparent_temperature,relative_humidity_2m,wind_speed_10m,wind_gusts_10m,weather_code`;\n\n  const response = await fetch(weatherUrl);\n  const data = (await response.json()) as WeatherResponse;\n\n  return {\n    temperature: data.current.temperature_2m,\n    feelsLike: data.current.apparent_temperature,\n    humidity: data.current.relative_humidity_2m,\n    windSpeed: data.current.wind_speed_10m,\n    windGust: data.current.wind_gusts_10m,\n    conditions: getWeatherCondition(data.current.weather_code),\n    location: name,\n  };","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp/src/__fixtures__/tools.ts#L23-L59","documentation":"getWeather geocodes a free-text location via the Open-Meteo geocoding API. If the response contains no results (results array empty or absent), the code throws 'Location \"X\" not found'. This happens for misspelled place names, overly specific strings, or places the geocoder does not know.","triggerScenarios":"Calling weatherTool with a location string that Open-Meteo geocoding cannot resolve: misspellings ('Nuuk' vs 'Nuugg'), non-city strings ('my house'), locations with only partial matches, or empty/whitespace-only strings.","commonSituations":"LLM agents passing imprecise location names; users entering addresses or POI names when the API only geocodes settlements; encoding/locale issues; transient upstream geocoding outages returning empty results.","solutions":["Correct the spelling or use a canonical place/city name ('San Francisco' not 'SF the city by the bay').","Disambiguate with country/state, e.g. 'Springfield, Illinois'.","Retry if the geocoding API returned an unexpected empty response (transient outage).","Pre-resolve coordinates yourself and skip geocoding if you already know lat/lon."],"exampleFix":"// before\nawait getWeather(\"silicon valley hq\");\n// after\nawait getWeather(\"San Jose, California\");","handlingStrategy":"fallback","validationCode":"// Pre-check the location string before calling the tool:\nfunction isPlausibleLocation(loc) {\n  return typeof loc === 'string' && loc.trim().length >= 2 && /[a-zA-Z\\u00C0-\\u024F]/.test(loc);\n}\nif (!isPlausibleLocation(userInput)) throw new TypeError('Provide a real place name, e.g. \"Paris, France\"');","typeGuard":"function isGeocodingHit(res: unknown): res is { results: Array<{ latitude: number; longitude: number; name: string }> } {\n  return typeof res === 'object' && res !== null &&\n    Array.isArray((res as any).results) && (res as any).results.length > 0;\n}","tryCatchPattern":"async function getWeatherSafe(location) {\n  try {\n    return await getWeather(location);\n  } catch (e) {\n    if (e instanceof Error && e.message.includes('not found')) {\n      // fallback: retry with disambiguated name, or inform the user\n      const alt = location.includes(',') ? location : location + ', ' + userCountryHint;\n      if (alt !== location) return getWeatherSafe(alt);\n      return { error: `Location \"${location}\" not found; try a canonical city name` };\n    }\n    throw e;\n  }\n}","preventionTips":["Normalize user input: trim, fix casing, append country/state for ambiguous names.","Offer an autocomplete/disambiguation step before calling the weather tool.","Cache resolved geocoding results for repeat queries.","Handle empty geocoding responses defensively even without an exception (results may be missing entirely)."],"tags":["network","geocoding","open-meteo","not-found"],"backgroundTag":"location-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}