eyaltoledano/claude-task-master · error · Error
Provider name is required
Error message
Provider name is required
What it means
OpenAICompatibleProvider's constructor validates that a provider configuration object includes a non-empty name and throws otherwise. The name is used for identification, error messages, and provider registry lookup. This is a fail-fast configuration validation at instantiation time.
Source
Thrown at src/ai-providers/openai-compatible.js:28
/**
* Base class for OpenAI-compatible providers (LM Studio, Z.ai, etc.)
* Provides a flexible foundation for any service with OpenAI-compatible endpoints.
*/
export class OpenAICompatibleProvider extends BaseAIProvider {
/**
* @param {object} config - Provider configuration
* @param {string} config.name - Provider display name
* @param {string} config.apiKeyEnvVar - Environment variable name for API key
* @param {boolean} [config.requiresApiKey=true] - Whether API key is required
* @param {string} [config.defaultBaseURL] - Default base URL for the API
* @param {Function} [config.getBaseURL] - Function to determine base URL from params
* @param {boolean} [config.supportsStructuredOutputs] - Whether provider supports structured outputs
*/
constructor(config) {
super();
if (!config.name) {
throw new Error('Provider name is required');
}
if (!config.apiKeyEnvVar) {
throw new Error('API key environment variable name is required');
}
this.name = config.name;
this.apiKeyEnvVar = config.apiKeyEnvVar;
this.requiresApiKey = config.requiresApiKey !== false; // Default to true
this.defaultBaseURL = config.defaultBaseURL;
this.getBaseURLFromParams = config.getBaseURL;
this.supportsStructuredOutputs = config.supportsStructuredOutputs;
}
/**
* Returns the environment variable name required for this provider's API key.
* @returns {string} The environment variable name for the API key
*/
getRequiredApiKeyName() {View on GitHub (pinned to c0c98d367c)
Solutions
- Add a 'name' property to the config object passed to the provider constructor.
- Check the source of the config (file/env/loader) for a missing or misnamed key.
- Validate config against the documented schema before instantiating.
- If loading many providers, log which config entry lacks a name.
Example fix
// before
// new OpenAICompatibleProvider({ apiKeyEnvVar: 'MY_KEY', defaultBaseURL: 'https://api.example.com/v1' })
// after
// new OpenAICompatibleProvider({ name: 'my-provider', apiKeyEnvVar: 'MY_KEY', defaultBaseURL: 'https://api.example.com/v1' }) Defensive patterns
Strategy: validation
Validate before calling
function assertProviderConfig(config) {
if (!config || typeof config !== 'object') throw new TypeError('config must be an object');
if (typeof config.name !== 'string' || !config.name.trim()) throw new Error('provider config.name is required');
} Type guard
function isValidProviderConfig(c) {
return typeof c === 'object' && c !== null && typeof c.name === 'string' && c.name.length > 0;
} Try / catch
try {
const provider = new OpenAICompatibleProvider(config);
} catch (e) {
if (e.message === 'Provider name is required') {
console.error('Config missing name:', JSON.stringify(Object.keys(config || {})));
}
throw e;
} Prevention
- Validate provider configs at startup before use
- Keep provider config schema documented and lint-checked
- Validate JSON/YAML provider definitions on load
- Always include name when constructing configs programmatically
When it happens
Trigger: new OpenAICompatibleProvider(config) where config.name is undefined, null, or empty string — typically a mis-built provider config passed from a registry or config file.
Common situations: Custom provider config objects missing the 'name' field, loading provider config from JSON/YAML where the key was renamed or omitted, constructing config programmatically and forgetting name.
Related errors
- API key environment variable name is required
- maxBufferSize must be positive
- Project path is required
- Project path must be an absolute path
- MISSING_CONFIGURATION
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/dd1a3bfea6d8f81e.
Report an issue: GitHub.