{"record":{"id":"48f53c5f020f7bce","repo":"eyaltoledano/claude-task-master","slug":"could-not-gather-context-contexterror-message","errorCode":null,"errorMessage":"Could not gather context: ${contextError.message}","messagePattern":"Could not gather context: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/modules/task-manager/expand-task.js","lineNumber":144,"sourceCode":"\t\t\tconst searchResults = fuzzySearch.findRelevantTasks(searchQuery, {\n\t\t\t\tmaxResults: 5,\n\t\t\t\tincludeSelf: true\n\t\t\t});\n\t\t\tconst relevantTaskIds = fuzzySearch.getTaskIds(searchResults);\n\n\t\t\tconst finalTaskIds = [\n\t\t\t\t...new Set([taskId.toString(), ...relevantTaskIds])\n\t\t\t];\n\n\t\t\tif (finalTaskIds.length > 0) {\n\t\t\t\tconst contextResult = await contextGatherer.gather({\n\t\t\t\t\ttasks: finalTaskIds,\n\t\t\t\t\tformat: 'research'\n\t\t\t\t});\n\t\t\t\tgatheredContext = contextResult.context || '';\n\t\t\t}\n\t\t} catch (contextError) {\n\t\t\tlogger.warn(`Could not gather context: ${contextError.message}`);\n\t\t}\n\t\t// --- End Context Gathering ---\n\n\t\t// --- Complexity Report Integration ---\n\t\tlet finalSubtaskCount;\n\t\tlet complexityReasoningContext = '';\n\t\tlet taskAnalysis = null;\n\n\t\tlogger.info(\n\t\t\t`Looking for complexity report at: ${complexityReportPath}${tag !== 'master' ? ` (tag-specific for '${tag}')` : ''}`\n\t\t);\n\n\t\ttry {\n\t\t\tif (fs.existsSync(complexityReportPath)) {\n\t\t\t\tconst complexityReport = readJSON(complexityReportPath);\n\t\t\t\ttaskAnalysis = complexityReport?.complexityAnalysis?.find(\n\t\t\t\t\t(a) => a.taskId === task.id\n\t\t\t\t);","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/expand-task.js#L126-L162","documentation":"During task expansion, expandTask tries to gather research context (e.g. from Perplexity) to enrich the expansion prompt. If context gathering throws (API error, missing key, network failure), the error is caught and only logged as a warning — expansion continues without the extra context.","triggerScenarios":"expandTask called (directly or via the 'result' path) with research enabled / 'research' format, and the context-gathering call (contextGatherer) rejects — e.g. missing PERPLEXITY_API_KEY, network failure, or API error.","commonSituations":"No research API key configured; offline or rate-limited; the chosen research provider returns an error; contextGatherer misconfigured for the requested format.","solutions":["Ignore if acceptable: expansion proceeds without research context; check earlier warnings for the root cause.","Set/verify the research provider API key (e.g. PERPLEXITY_API_KEY) in .env or mcp.json.","Re-run with a working network or switch the research provider via 'task-master models --set-research'.","Inspect contextError.message in logs to address the underlying provider error."],"exampleFix":"// before: expansion run with research but no key set\n// .env missing PERPLEXITY_API_KEY\n// after\n# .env\nPERPLEXITY_API_KEY=pplx-xxxxxxxx","handlingStrategy":"fallback","validationCode":"const hasKey = !!(process.env.PERPLEXITY_API_KEY || mcpKeyFor('perplexity'));\nif (!hasKey) console.warn('Research context will be skipped: no API key');","typeGuard":null,"tryCatchPattern":"try {\n  await expandTask(taskId, { research: true });\n} catch (e) {\n  // expandTask rarely throws for context issues; check warnings instead\n  console.error('Expansion failed:', e.message);\n}","preventionTips":["Set PERPLEXITY_API_KEY in .env or .cursor/mcp.json before using --research.","Treat context-gathering warnings as optional: expansion output is valid without it.","Check network/proxy availability in CI when research mode is enabled."],"tags":["context-gathering","api","optional-feature"],"backgroundTag":"api-key-missing","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}