mastra-ai/mastra · error

Input data not found

Error message

Input data not found

What it means

The default weather tool's execute() in AgentBuilderDefaults throws 'Input data not found' when inputData is falsy. The tool has an inputSchema requiring a 'city' string, but Mastra passes inputData explicitly and it can be missing/undefined when the workflow step is invoked without input. This is a defensive guard inside the built-in demo tool shipped with the agent builder defaults.

Source

Thrown at packages/agent-builder/src/defaults.ts:284

});
\`\`\`

### Weather Workflow
\`\`\`
// ./src/workflows/weather-workflow.ts
import { createStep, createWorkflow } from '@mastra/core/workflows';
import { z } from 'zod';

const fetchWeather = createStep({
  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}&current=precipitation,weathercode&timezone=auto,&hourly=precipitation_probability,temperature_2m\`
    const response = await fetch(weatherUrl);
    const data = (await response.json()) as {
      current: {

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Start the workflow with a trigger payload matching the inputSchema, e.g. { city: 'London' }
  2. Verify the step's input wiring so inputData flows from the previous step or trigger
  3. If calling the tool directly, always pass { city: '...' } as the argument
  4. Upgrade @mastra/core so schema validation runs before execute and rejects empty input earlier

Example fix

// before
const result = await mastra.getWorkflow('weatherWorkflow').start();

// after
const result = await mastra.getWorkflow('weatherWorkflow').start({
  triggerData: { city: 'San Francisco' },
});
Defensive patterns

Strategy: validation

Validate before calling

const trigger = { city: 'London' };
if (!trigger || typeof trigger.city !== 'string' || trigger.city.length === 0) {
  throw new Error('city is required before starting weather workflow');
}
await mastra.getWorkflow('weatherWorkflow').start({ triggerData: trigger });

Prevention

When it happens

Trigger: Triggering the default weather workflow step whose input schema is { city: string } with undefined/null inputData — e.g. a workflow run started without a trigger payload, a step wired so its input mapping produces nothing, or an agent/tool invocation that bypasses schema validation.

Common situations: Running the scaffolded weather workflow without providing a triggerData object; editing the workflow so the step's input reference no longer resolves; calling the tool programmatically with no argument; older/newer core versions changing how inputData is injected into step execute.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/1f055396c6e39eb6. Report an issue: GitHub.