{"record":{"id":"477acf3520f37b7e","repo":"eyaltoledano/claude-task-master","slug":"this-name-api-key-is-required-477acf","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/openai-compatible.js","lineNumber":64,"sourceCode":"\tgetRequiredApiKeyName() {\n\t\treturn this.apiKeyEnvVar;\n\t}\n\n\t/**\n\t * Returns whether this provider requires an API key.\n\t * @returns {boolean} True if API key is required\n\t */\n\tisRequiredApiKey() {\n\t\treturn this.requiresApiKey;\n\t}\n\n\t/**\n\t * Override auth validation based on requiresApiKey setting\n\t * @param {object} params - Parameters to validate\n\t */\n\tvalidateAuth(params) {\n\t\tif (this.requiresApiKey && !params.apiKey) {\n\t\t\tthrow new Error(`${this.name} API key is required`);\n\t\t}\n\t}\n\n\t/**\n\t * Determines the base URL to use for the API.\n\t * @param {object} params - Client parameters\n\t * @returns {string|undefined} The base URL to use\n\t */\n\tgetBaseURL(params) {\n\t\t// If custom baseURL provided in params, use it\n\t\tif (params.baseURL) {\n\t\t\treturn params.baseURL;\n\t\t}\n\n\t\t// If provider has a custom getBaseURL function, use it\n\t\tif (this.getBaseURLFromParams) {\n\t\t\treturn this.getBaseURLFromParams(params);\n\t\t}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/ai-providers/openai-compatible.js#L46-L82","documentation":"validateAuth throws when the provider is configured with requiresApiKey=true (the default) and no API key is present in params.apiKey. It interpolates the provider's name so you know which provider's credentials are missing.","triggerScenarios":"Calling an API method (via getClient/validateAuth) without an apiKey param while the provider config does not set requiresApiKey: false.","commonSituations":"Environment variable named in apiKeyEnvVar is unset, .env file not loaded, key set under a different variable name, or provider genuinely needs no key but config didn't set requiresApiKey:false.","solutions":["Set the API key in the environment variable specified by the provider's apiKeyEnvVar config.","Ensure your .env file is loaded (dotenv config) before creating the client.","Pass apiKey explicitly in the params if not relying on env vars.","If the provider needs no key, set requiresApiKey: false in the provider config."],"exampleFix":"// before\n// MY_PROVIDER_KEY=  (empty)\n// after\n// echo 'export MY_PROVIDER_KEY=sk-...' >> ~/.bashrc && source ~/.bashrc","handlingStrategy":"validation","validationCode":"function assertApiKey(provider, params = {}) {\n  if (provider.requiresApiKey !== false && !params.apiKey) {\n    const key = process.env[provider.apiKeyEnvVar];\n    if (!key) throw new Error(`Set ${provider.apiKeyEnvVar} before calling ${provider.name}`);\n    return { ...params, apiKey: key };\n  }\n  return params;\n}","typeGuard":"function hasApiKey(p) {\n  return typeof p === 'object' && p !== null && typeof p.apiKey === 'string' && p.apiKey.length > 0;\n}","tryCatchPattern":"try {\n  await provider.validateAuth(params);\n} catch (e) {\n  if (e.message.endsWith('API key is required')) {\n    console.error(`Missing key: export ${provider.apiKeyEnvVar}=<your key>`);\n    process.exitCode = 1;\n    return;\n  }\n  throw e;\n}","preventionTips":["Load .env files before constructing clients","Check required env vars at app startup with a fail-fast check","Set requiresApiKey: false for keyless providers","Never rely on keys being present in CI — inject them as secrets"],"tags":["api-key","missing-credential","environment-variable","openai-compatible"],"backgroundTag":"missing-api-key","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}