{"record":{"id":"3a612815ad869237","repo":"mastra-ai/mastra","slug":"parallel-operation-returned-no-output","errorCode":null,"errorMessage":"Parallel ${operation} returned no output","messagePattern":"Parallel (.+?) returned no output","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/sdk/src/tools/web-search.ts","lineNumber":20,"sourceCode":"import { createParallelSearchTool, createParallelExtractTool } from '@mastra/parallel';\nimport { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily';\nimport { z } from 'zod';\n\nimport { 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","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/sdk/src/tools/web-search.ts#L2-L38","documentation":"requireParallelOutput normalizes results of parallel web search/extract sub-calls. When the underlying tool call returns undefined (no output at all), it throws this error instead of letting undefined flow into the schema result. It exists so parallel batch results always carry a concrete payload or a descriptive error.","triggerScenarios":"Calling the parallel web-search/extract tool path where a single search or extract sub-operation resolves to undefined — e.g. the model/tool returned void or the provider produced no result object.","commonSituations":"Provider outages or rate limits yielding empty tool results; a model that answered with no tool output; bug in a custom search provider returning nothing.","solutions":["Retry the operation; transient provider failures are the most common cause.","Verify the search provider/API key is valid and returning results (test a direct query).","Inspect the parallel sub-operation implementation to ensure it returns its result rather than an implicit undefined."],"exampleFix":"// before: custom provider path that can fall through\nasync function search(q) { if (!apiKey) return; }\n// after\nasync function search(q) {\n  if (!apiKey) throw new Error('web search provider not configured');\n  return await doSearch(q);\n}","handlingStrategy":"try-catch","validationCode":"if (!process.env.SEARCH_PROVIDER_API_KEY) throw new Error('search provider unconfigured — parallel search will return no output');","typeGuard":"function hasOutput<T>(o: T | undefined | null): o is T { return o !== undefined && o !== null; }","tryCatchPattern":"try { const res = await parallelWebSearch(query); } catch (e) { if (String(e.message).includes('returned no output')) { /* retry or fall back to single search */ } else throw e; }","preventionTips":["Retry transient empty results with backoff.","Validate provider config/API keys before invoking parallel search.","Monitor provider status; empty outputs often correlate with provider incidents."],"tags":["web-search","empty-result","tool-output"],"backgroundTag":"tool-returned-no-output","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}