{"record":{"id":"fa9b4f63ec27cb75","repo":"eyaltoledano/claude-task-master","slug":"this-name-api-key-is-required","errorCode":null,"errorMessage":"${this.name} API key is required","messagePattern":"(.+?) API key is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/ai-providers/base-provider.js","lineNumber":161,"sourceCode":"\t\t */\n\t\tthis.needsExplicitJsonSchema = false;\n\n\t\t/**\n\t\t * Whether this provider supports temperature parameter\n\t\t * Can be overridden by subclasses\n\t\t * @type {boolean}\n\t\t */\n\t\tthis.supportsTemperature = true;\n\t}\n\n\t/**\n\t * Validates authentication parameters - can be overridden by providers\n\t * @param {object} params - Parameters to validate\n\t */\n\tvalidateAuth(params) {\n\t\t// Default: require API key (most providers need this)\n\t\tif (!params.apiKey) {\n\t\t\tthrow new Error(`${this.name} API key is required`);\n\t\t}\n\t}\n\n\t/**\n\t * Creates a custom fetch function with proxy support.\n\t * Only enables proxy when TASKMASTER_ENABLE_PROXY environment variable is set to 'true'\n\t * or enableProxy is set to true in config.json.\n\t * Automatically reads http_proxy/https_proxy environment variables when enabled.\n\t * @returns {Function} Custom fetch function with proxy support, or undefined if proxy is disabled\n\t */\n\tcreateProxyFetch() {\n\t\t// Cache project root to avoid repeated lookups\n\t\tif (!this._projectRoot) {\n\t\t\tthis._projectRoot = findProjectRoot();\n\t\t}\n\t\tconst projectRoot = this._projectRoot;\n\n\t\tif (!isProxyEnabled(null, projectRoot)) {","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/ai-providers/base-provider.js#L143-L179","documentation":"The default validateAuth() on BaseAIProvider requires params.apiKey for providers that don't override it. Since ${this.name} resolves to the concrete provider's class name, the message identifies which provider is missing its key. It fails fast so requests never reach the remote API unauthenticated.","triggerScenarios":"Calling any generation method on a provider using the default validateAuth when params.apiKey is undefined/null/empty — e.g., provider env var like OPENAI_API_KEY or ANTHROPIC_API_KEY unset, or apiKey omitted in direct instantiation.","commonSituations":"Missing env var / unexported key; .env not loaded; key configured for a different provider than the active role; providers like ollama that override validateAuth are unaffected.","solutions":["Set the provider's API key env var (e.g., OPENAI_API_KEY) or pass apiKey in params","Run `tm models --setup` to configure credentials for the active role","Check the provider name in the message to know which key is missing"],"exampleFix":"// before\nconst provider = new OpenAIProvider({});\n// after\nconst provider = new OpenAIProvider({ apiKey: process.env.OPENAI_API_KEY });","handlingStrategy":"validation","validationCode":"if (!params?.apiKey) throw new Error(`Provide an API key for ${providerName} before calling the provider`);","typeGuard":"function hasApiKey(params) { return typeof params?.apiKey === 'string' && params.apiKey.length > 0; }","tryCatchPattern":"try {\n  await provider.generateText(params);\n} catch (err) {\n  if (err.message.endsWith('API key is required')) {\n    console.error(`Missing API key for ${provider.name}; check env/config`);\n  } else throw err;\n}","preventionTips":["Load .env at process start and verify required keys exist","Match the key env var to the actual active provider","Run `tm models --setup` after changing provider roles"],"tags":["api-key","authentication","configuration","provider"],"backgroundTag":"missing-api-key","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}