eyaltoledano/claude-task-master · error · Error
Provider name must be a non-empty string
Error message
Provider name must be a non-empty string
What it means
registerProvider() is the registration entry point of the provider registry singleton. It first validates that the provider name key is a truthy, non-empty string, since the name is used as the Map key for lookup and must support getProvider(name) calls. Empty strings, non-strings, and undefined are all rejected with this error.
Source
Thrown at src/provider-registry/index.js:57
initialize() {
if (this._initialized) {
return this;
}
this._initialized = true;
return this;
}
/**
* Register a provider with the registry
* @param {string} providerName - The name of the provider
* @param {object} provider - The provider instance
* @param {object} options - Additional options for registration
* @returns {ProviderRegistry} The singleton instance for chaining
*/
registerProvider(providerName, provider, options = {}) {
if (!providerName || typeof providerName !== 'string') {
throw new Error('Provider name must be a non-empty string');
}
if (!provider) {
throw new Error('Provider instance is required');
}
// Validate that provider implements the required interface
if (
typeof provider.generateText !== 'function' ||
typeof provider.streamText !== 'function' ||
typeof provider.generateObject !== 'function'
) {
throw new Error('Provider must implement BaseAIProvider interface');
}
// Add provider to the registry
this._providers.set(providerName, {
instance: provider,View on GitHub (pinned to c0c98d367c)
Solutions
- Pass a non-empty string as the first argument, e.g. registry.registerProvider('openai', provider, options).
- If the name comes from config/env, default or validate it first: const name = process.env.AI_PROVIDER || 'openai'.
- Check argument order — a provider object passed first will hit this error.
- Use registerRemoteProvider if you want the registry to resolve the name for you.
Example fix
// before
const name = process.env.AI_PROVIDER; // may be undefined
registry.registerProvider(name, provider);
// after
const name = process.env.AI_PROVIDER;
if (!name) throw new Error('AI_PROVIDER env var is required');
registry.registerProvider(name, provider); Defensive patterns
Strategy: validation
Validate before calling
function assertProviderName(name) {
if (typeof name !== 'string' || name.length === 0) {
throw new TypeError(`providerName must be a non-empty string, got: ${JSON.stringify(name)}`);
}
}
assertProviderName(name);
registry.registerProvider(name, provider, options); Type guard
const isValidProviderName = (n) => typeof n === 'string' && n.trim().length > 0;
Try / catch
try {
registry.registerProvider(name, provider, options);
} catch (err) {
if (err.message.startsWith('Provider name must be')) {
throw new Error(`Invalid provider name "${name}" — check AI_PROVIDER config`);
}
throw err;
} Prevention
- Default env-derived names: process.env.AI_PROVIDER || 'openai'.
- Double-check argument order (name, provider, options).
- Validate config files at startup before registering providers.
- Keep provider names in a constants module to avoid typos/empty strings.
When it happens
Trigger: registerProvider('', provider), registerProvider(null, provider), registerProvider(undefined, provider), registerProvider(123, provider), or registerProvider(config.providerName, provider) where config.providerName is unset/empty.
Common situations: Reading the provider name from environment variables or config files that are missing (e.g. unset AI_PROVIDER env var); typos in config keys yielding empty strings; passing an options object positionally so the provider lands in the name slot.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- Provider instance is required
- Invalid maxAttempts value: ${maxAttempts}. Must be a positiv
- Invalid subtask ID format: ${subtaskId}. Expected format: "p
- Payload must be an object
- Provider must implement BaseAIProvider interface
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/ab5ca270a24c298c.
Report an issue: GitHub.