mastra-ai/mastra · error

Forecast data not found

Error message

Forecast data not found

What it means

The default workflow step that consumes the forecast (and hands it to the weather agent) throws 'Forecast data not found' when its inputData is falsy. The step expects the previous weather step's output (forecastSchema) to be delivered as inputData; a missing input means the upstream step did not run or its output was not mapped.

Source

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

    };

    return forecast;
  },
});

const planActivities = createStep({
  id: 'plan-activities',
  description: 'Suggests activities based on weather conditions',
  inputSchema: forecastSchema,
  outputSchema: z.object({
    activities: z.string(),
  }),
  execute: async (inputData, context) => {
    const mastra = context?.mastra;
    const forecast = inputData;

    if (!forecast) {
      throw new Error('Forecast data not found');
    }

    const agent = mastra?.getAgent('weatherAgent');
    if (!agent) {
      throw new Error('Weather agent not found');
    }

    const prompt = \${weatherWorkflowPrompt}

    const response = await agent.stream([
      {
        role: 'user',
        content: prompt,
      },
    ]);

    let activitiesText = '';

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Ensure the forecast-producing step runs successfully before this step (check its status/output in Studio or run logs)
  2. Fix the step's variable mapping so it reads the previous step's output (context.getStepResult(...))
  3. Make the upstream step's failure fail the workflow instead of continuing to this step
  4. Pass the forecast explicitly if invoking this step's execute in tests: execute({ inputData: forecast, context })

Example fix

// before
const forecast = context.getStepResult<{ summary: string }>('missingStepName');

// after
const forecast = context.getStepResult<WeatherForecast>(forecastStepId);
Defensive patterns

Strategy: try-catch

Try / catch

const run = await mastra.getWorkflow('weatherWorkflow').start({ triggerData: { city } });
try {
  // ... observe downstream steps
} catch (e) {
  if (e instanceof Error && e.message === 'Forecast data not found') {
    // check the upstream forecast step's status/output before retrying
  } else throw e;
}

Prevention

When it happens

Trigger: Running the second workflow step when the preceding weather tool step was skipped/failed without stopping the workflow, the step input mapping is broken, or the workflow is started with an empty trigger so the forecast-producing step produced no output for this step.

Common situations: Editing the default weather workflow and rewiring step variables incorrectly; a weather step error swallowed upstream so the downstream step receives undefined; replaying/inspecting steps in Studio out of order.

Related errors


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