{"record":{"id":"5c6e56b980931cc7","repo":"mastra-ai/mastra","slug":"response-error-llms-txt-generation-failed","errorCode":null,"errorMessage":"${response.error || 'LLMs.txt generation failed'}","messagePattern":"\\$\\{response\\.error \\|\\| 'LLMs\\.txt generation failed'\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/__fixtures__/fire-crawl-complex-schema.ts","lineNumber":912,"sourceCode":"\n      case 'firecrawl_generate_llmstxt': {\n        if (!isGenerateLLMsTextOptions(args)) {\n          throw new Error('Invalid arguments for firecrawl_generate_llmstxt');\n        }\n\n        try {\n          const { url, ...params } = args;\n          const generateStartTime = Date.now();\n\n          safeLog('info', `Starting LLMs.txt generation for URL: ${url}`);\n\n          const response = await withRetry(\n            async () => client.generateLLMsText(url, { ...params }),\n            'LLMs.txt generation',\n          );\n\n          if (!response.success) {\n            throw new Error(response.error || 'LLMs.txt generation failed');\n          }\n\n          safeLog('info', `LLMs.txt generation completed in ${Date.now() - generateStartTime}ms`);\n\n          let resultText = '';\n\n          if ('data' in response) {\n            resultText = `LLMs.txt content:\\n\\n${response.data.llmstxt}`;\n\n            if (args.showFullText && response.data.llmsfulltxt) {\n              resultText += `\\n\\nLLMs-full.txt content:\\n\\n${response.data.llmsfulltxt}`;\n            }\n          }\n\n          return {\n            content: [{ type: 'text', text: trimResponseText(resultText) }],\n            isError: false,\n          };","sourceCodeStart":894,"sourceCodeEnd":930,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp/src/__fixtures__/fire-crawl-complex-schema.ts#L894-L930","documentation":"The LLMs.txt generation call's response is checked for response.success after withRetry; on failure the server throws the API's error message or 'LLMs.txt generation failed'. LLMs.txt generation is an async Firecrawl job (crawl + summarize), so the error can come from job state as well as auth/limits.","triggerScenarios":"response.success is false after generation completes/fails — invalid API key, rate limits during the underlying crawl, credit exhaustion, the target site blocking the crawl, or the generation job expiring.","commonSituations":"Generating LLMs.txt for very large sites where the job times out or burns credits; sites with bot protection returning failures for every crawled page; intermittent Firecrawl 5xx during long jobs.","solutions":["Log/inspect response.error for the concrete API cause (auth vs rate limit vs job failure).","Verify API key and credit balance; large sites consume many credits.","Lower maxUrls or retry with backoff for transient failures; re-run the generation.","Check Firecrawl status page for degraded crawl/search performance before retrying."],"exampleFix":"// before\nif (!response.success) {\n  throw new Error(response.error || 'LLMs.txt generation failed');\n}\n// after\nif (!response.success) {\n  const detail = response.error || 'no detail';\n  if (/timeout|expired/i.test(detail)) throw new Error(`Generation job timed out, retry with smaller maxUrls: ${detail}`);\n  throw new Error(`LLMs.txt generation failed: ${detail}`);\n}","handlingStrategy":"retry","validationCode":"// Pre-flight: valid URL + key present; scope large sites down\nif (!process.env.FIRECRAWL_API_KEY) throw new Error('FIRECRAWL_API_KEY missing');\nif (!/^https?:\\/\\//.test(args?.url ?? '')) throw new TypeError('url must be absolute http(s)');\nif ((args.maxUrls ?? 0) > 500) console.warn('maxUrls>500 may exhaust credits or time out');","typeGuard":"function isLlmsTxtSuccess(res: unknown): res is { success: true; data: { llmstxt?: string; llmsFullTxt?: string } } {\n  return typeof res === 'object' && res !== null && (res as any).success === true;\n}","tryCatchPattern":"try {\n  const res = await generateLlmsTxt(url, params);\n  if (!res.success) throw new Error(res.error || 'LLMs.txt generation failed');\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (/429|rate|timeout|temporarily/i.test(msg)) return withBackoff(() => generateLlmsTxt(url, { ...params, maxUrls: Math.min(params.maxUrls ?? 100, 50) }), 3);\n  if (/401|403|credit/i.test(msg)) throw new Error('Fix Firecrawl auth/credits: ' + msg);\n  throw e;\n}","preventionTips":["Cap maxUrls for large sites to avoid timeouts and credit drain.","Retry transient failures with backoff; do not blindly retry credit errors.","Verify API key before long-running generation jobs.","Log the raw response.error to distinguish job failures from auth failures."],"tags":["network","api-error","firecrawl","async-job"],"backgroundTag":"api-request-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}