mastra-ai/mastra · error

${output.message}

Error message

${output.message}

What it means

When the parallel web-search/extract sub-operation returns a ValidationError instead of a result, requireParallelOutput rethrows its message as a plain Error. The library surfaces schema/provider validation failures this way so the caller sees the underlying validation problem.

Source

Thrown at mastracode/sdk/src/tools/web-search.ts:24

import { loadSettings, type WebSearchProviderSetting } from '../onboarding/settings.js';
import { truncateStringForTokenEstimate } from '../utils/token-estimator.js';

const MAX_WEB_SEARCH_TOKENS = 2_000;
const MAX_WEB_EXTRACT_TOKENS = 2_000;

const MIN_RELEVANCE_SCORE = 0.25;

const parallelWebSearchInputSchema = z.object({
  query: z.string().min(1).describe('The search query'),
});

function requireParallelOutput<T>(output: T | ValidationError | void, operation: 'search' | 'extract'): T {
  if (output === undefined) {
    throw new Error(`Parallel ${operation} returned no output`);
  }

  if (isValidationError(output)) {
    throw new Error(output.message);
  }

  return output;
}

/**
 * Check whether a Tavily API key is available in the environment.
 * Used to select model-independent web tools before falling back to
 * model-native web search.
 */
export function hasTavilyKey(): boolean {
  return !!process.env.TAVILY_API_KEY;
}

/** Check whether a Parallel API key is available in the environment. */
export function hasParallelKey(): boolean {
  return !!process.env.PARALLEL_API_KEY;
}

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Read the embedded message (the rethrown text) to identify which field failed validation.
  2. Retry with a simpler/shorter query; malformed model arguments often resolve on retry.
  3. If persistent, check that tool input/output schemas match the provider's current response format.
Defensive patterns

Strategy: validation

Validate before calling

// validate query before calling
if (typeof query !== 'string' || query.trim().length === 0) throw new Error('query must be a non-empty string');

Type guard

function isValidationError(o: unknown): o is { message: string } { return !!o && typeof o === 'object' && 'message' in o && !('results' in o); }

Try / catch

try { const res = await parallelWebSearch(query); } catch (e) { /* e.message is the underlying validation failure — log and retry with simplified args */ }

Prevention

When it happens

Trigger: A search or extract sub-call in the parallel path returns an isValidationError(output)-positive object — i.e. the tool output failed input/output schema validation.

Common situations: Model produced malformed arguments for search/extract; provider response shape changed; truncation produced invalid JSON.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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