{"record":{"id":"57a433ccf138a80c","repo":"mastra-ai/mastra","slug":"output-message","errorCode":null,"errorMessage":"${output.message}","messagePattern":"\\$\\{output\\.message\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/sdk/src/tools/web-search.ts","lineNumber":24,"sourceCode":"import { loadSettings, type WebSearchProviderSetting } from '../onboarding/settings.js';\nimport { truncateStringForTokenEstimate } from '../utils/token-estimator.js';\n\nconst MAX_WEB_SEARCH_TOKENS = 2_000;\nconst MAX_WEB_EXTRACT_TOKENS = 2_000;\n\nconst MIN_RELEVANCE_SCORE = 0.25;\n\nconst parallelWebSearchInputSchema = z.object({\n  query: z.string().min(1).describe('The search query'),\n});\n\nfunction requireParallelOutput<T>(output: T | ValidationError | void, operation: 'search' | 'extract'): T {\n  if (output === undefined) {\n    throw new Error(`Parallel ${operation} returned no output`);\n  }\n\n  if (isValidationError(output)) {\n    throw new Error(output.message);\n  }\n\n  return output;\n}\n\n/**\n * Check whether a Tavily API key is available in the environment.\n * Used to select model-independent web tools before falling back to\n * model-native web search.\n */\nexport function hasTavilyKey(): boolean {\n  return !!process.env.TAVILY_API_KEY;\n}\n\n/** Check whether a Parallel API key is available in the environment. */\nexport function hasParallelKey(): boolean {\n  return !!process.env.PARALLEL_API_KEY;\n}","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/sdk/src/tools/web-search.ts#L6-L42","documentation":"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.","triggerScenarios":"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.","commonSituations":"Model produced malformed arguments for search/extract; provider response shape changed; truncation produced invalid JSON.","solutions":["Read the embedded message (the rethrown text) to identify which field failed validation.","Retry with a simpler/shorter query; malformed model arguments often resolve on retry.","If persistent, check that tool input/output schemas match the provider's current response format."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate query before calling\nif (typeof query !== 'string' || query.trim().length === 0) throw new Error('query must be a non-empty string');","typeGuard":"function isValidationError(o: unknown): o is { message: string } { return !!o && typeof o === 'object' && 'message' in o && !('results' in o); }","tryCatchPattern":"try { const res = await parallelWebSearch(query); } catch (e) { /* e.message is the underlying validation failure — log and retry with simplified args */ }","preventionTips":["Keep queries concise to avoid malformed model-generated tool args.","Pin provider API versions so response shapes stay stable.","Log the embedded validation message to identify the failing field."],"tags":["web-search","schema-validation","tool-output"],"backgroundTag":"schema-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}