Purpose: Common errors, their causes, and recovery strategies.
Last Updated: 2026-01-09
Errors in Mastra typically fall into three categories: AI generation failures, structured output validation errors, and context/resource missing errors.
retryAfter value.services or mastra instance) is missing from the execution context.isRetryableError(error) to determine if a transient failure can be recovered with exponential backoff.| Error | Cause | Fix |
|---|---|---|
StructuredOutputError |
LLM hallucinated wrong JSON | Refine prompt or use simpler schema |
RateLimitError |
Too many concurrent requests | Implement rate limiting or increase quota |
NotFoundError |
Case or Document ID missing in DB | Check DB state before workflow start |
MastraContextError |
services not passed to tool |
Ensure services is in ToolExecutionContext |
Reference: src/lib/errors.ts
Related: