{"record":{"id":"6e052e580036fbf9","repo":"eyaltoledano/claude-task-master","slug":"read-error","errorCode":"READ_ERROR","errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/complexity-report.js","lineNumber":78,"sourceCode":"\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\treport,\n\t\t\t\t\t\treportPath\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\t// Make sure to restore normal logging even if there's an error\n\t\t\t\tdisableSilentMode();\n\n\t\t\t\tlog.error(`Error reading complexity report: ${error.message}`);\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tcode: 'READ_ERROR',\n\t\t\t\t\t\tmessage: error.message\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\n\t\t// Use the caching utility\n\t\ttry {\n\t\t\tconst result = await coreActionFn();\n\t\t\tlog.info('complexityReportDirect completed');\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\t// Ensure silent mode is disabled\n\t\t\tdisableSilentMode();\n\n\t\t\tlog.error(`Unexpected error during complexityReport: ${error.message}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/complexity-report.js#L60-L96","documentation":"This is the inner catch block around reading and parsing the complexity report file. Any error thrown while reading/parsing (permission denied, malformed JSON, EISDIR) is caught and returned as a READ_ERROR with the underlying error message preserved. It exists so the MCP tool returns a structured failure rather than propagating an exception.","triggerScenarios":"fs read of reportPath throws: file exists but is unreadable (permissions), path is a directory, report JSON is corrupted/truncated mid-write, or the parser throws on invalid JSON.","commonSituations":"Report file partially written by a crashed analyze run; running MCP server under a user lacking read permission on .taskmaster/reports; someone hand-edited the JSON and broke syntax; reportPath accidentally points to a directory.","solutions":["Read the message field of the error — it contains the underlying fs/parse error (e.g. EACCES, EISDIR, JSON parse position)","Regenerate the report with analyze-complexity to replace a corrupted file","Fix file permissions (chmod/chown) so the process running the MCP server can read the report","Verify reportPath is a file, not a directory","Validate the report JSON manually (jq . report.json) to confirm it parses"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try { JSON.parse(fs.readFileSync(reportPath, 'utf8')); } catch (e) { /* regenerate report */ }","typeGuard":"function isReadableFile(p) { try { fs.accessSync(p, fs.constants.R_OK); return fs.statSync(p).isFile(); } catch { return false; } }","tryCatchPattern":"const res = await complexityReportDirect({ reportPath }); if (!res.success && res.error.code === 'READ_ERROR') { log(res.error.message); await regenerateReport(); }","preventionTips":["Validate the report JSON parses before consuming","Ensure the MCP server process has read permission on .taskmaster/reports","Regenerate reports after crashes or version upgrades"],"tags":["mcp","file-read","json-parse"],"backgroundTag":"file-read-error","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}