{"record":{"id":"e36cdb21070a9299","repo":"eyaltoledano/claude-task-master","slug":"api-key-status-error","errorCode":"API_KEY_STATUS_ERROR","errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/models.js","lineNumber":824,"sourceCode":"\t\t\t\tcli: cliOk,\n\t\t\t\tmcp: mcpOk\n\t\t\t};\n\t\t});\n\n\t\treport('info', 'Successfully generated API key status report.');\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tdata: {\n\t\t\t\treport: statusReport,\n\t\t\t\tmessage: 'API key status report generated.'\n\t\t\t}\n\t\t};\n\t} catch (error) {\n\t\treport('error', `Error generating API key status report: ${error.message}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: 'API_KEY_STATUS_ERROR',\n\t\t\t\tmessage: error.message\n\t\t\t}\n\t\t};\n\t}\n}\n\nexport {\n\tgetModelConfiguration,\n\tgetAvailableModelsList,\n\tsetModel,\n\tgetApiKeyStatusReport\n};\n","sourceCodeStart":806,"sourceCodeEnd":837,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/models.js#L806-L837","documentation":"Catch-all wrapper in getApiKeyStatusReport(): any unexpected exception while building the per-provider API key status report is returned under API_KEY_STATUS_ERROR with the underlying error's message. getApiKeyStatusReport inspects config and environment for each supported provider, so failures usually come from reading config or probing environment variables.","triggerScenarios":"Calling getApiKeyStatusReport() (via apiKeyStatusResult) when getConfig() throws on malformed config JSON, an fs error occurs reading the config file, or a provider-status helper throws on unexpected environment/config shapes.","commonSituations":"Corrupted or hand-edited .taskmaster/config.json; wrong working directory so projectRoot detection fails; environment with restricted access to process.env or an fs permission error; partially upgraded config missing expected keys.","solutions":["Check the wrapped error.message for the root cause and validate .taskmaster/config.json parses as JSON.","Run from the project root (or pass the correct projectRoot) so the config file is found.","Restore a clean config with `task-master init` (back up the old one first) and re-run `task-master models --status`.","Update task-master; if the crash is in library code, file an issue with the error message."],"exampleFix":"// before\nconst status = await getApiKeyStatusReport(); // throws: 'Unexpected token } in JSON'\n// after\nconst raw = JSON.parse(fs.readFileSync('.taskmaster/config.json', 'utf8')); // fix file first\nconst status = await getApiKeyStatusReport();","handlingStrategy":"try-catch","validationCode":"const fs = require('fs');\nif (!fs.existsSync('.taskmaster/config.json')) throw new Error('Run task-master init first');\nJSON.parse(fs.readFileSync('.taskmaster/config.json', 'utf8')); // throws early on corrupt config","typeGuard":null,"tryCatchPattern":"try {\n  const res = await getApiKeyStatusReport(projectRoot);\n  if (!res.success && res.error?.code === 'API_KEY_STATUS_ERROR') {\n    console.error(`Key status check failed: ${res.error.message}`);\n  }\n} catch (e) {\n  console.error('Unhandled API key status failure:', e.message);\n}","preventionTips":["Verify the config file exists and parses before status/report calls.","Run status commands from the project root so projectRoot resolution succeeds.","Treat the wrapped error.message as the real diagnosis and log it verbatim.","Regenerate the config with `task-master init` after failed upgrades or manual migrations."],"tags":["exception","api-key","configuration"],"backgroundTag":"unexpected-exception-wrapped","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}