{"record":{"id":"ab5ca270a24c298c","repo":"eyaltoledano/claude-task-master","slug":"provider-name-must-be-a-non-empty-string","errorCode":null,"errorMessage":"Provider name must be a non-empty string","messagePattern":"Provider name must be a non-empty string","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/provider-registry/index.js","lineNumber":57,"sourceCode":"\tinitialize() {\n\t\tif (this._initialized) {\n\t\t\treturn this;\n\t\t}\n\n\t\tthis._initialized = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Register a provider with the registry\n\t * @param {string} providerName - The name of the provider\n\t * @param {object} provider - The provider instance\n\t * @param {object} options - Additional options for registration\n\t * @returns {ProviderRegistry} The singleton instance for chaining\n\t */\n\tregisterProvider(providerName, provider, options = {}) {\n\t\tif (!providerName || typeof providerName !== 'string') {\n\t\t\tthrow new Error('Provider name must be a non-empty string');\n\t\t}\n\n\t\tif (!provider) {\n\t\t\tthrow new Error('Provider instance is required');\n\t\t}\n\n\t\t// Validate that provider implements the required interface\n\t\tif (\n\t\t\ttypeof provider.generateText !== 'function' ||\n\t\t\ttypeof provider.streamText !== 'function' ||\n\t\t\ttypeof provider.generateObject !== 'function'\n\t\t) {\n\t\t\tthrow new Error('Provider must implement BaseAIProvider interface');\n\t\t}\n\n\t\t// Add provider to the registry\n\t\tthis._providers.set(providerName, {\n\t\t\tinstance: provider,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/provider-registry/index.js#L39-L75","documentation":"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.","triggerScenarios":"registerProvider('', provider), registerProvider(null, provider), registerProvider(undefined, provider), registerProvider(123, provider), or registerProvider(config.providerName, provider) where config.providerName is unset/empty.","commonSituations":"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.","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."],"exampleFix":"// before\nconst name = process.env.AI_PROVIDER; // may be undefined\nregistry.registerProvider(name, provider);\n// after\nconst name = process.env.AI_PROVIDER;\nif (!name) throw new Error('AI_PROVIDER env var is required');\nregistry.registerProvider(name, provider);","handlingStrategy":"validation","validationCode":"function assertProviderName(name) {\n  if (typeof name !== 'string' || name.length === 0) {\n    throw new TypeError(`providerName must be a non-empty string, got: ${JSON.stringify(name)}`);\n  }\n}\nassertProviderName(name);\nregistry.registerProvider(name, provider, options);","typeGuard":"const isValidProviderName = (n) => typeof n === 'string' && n.trim().length > 0;","tryCatchPattern":"try {\n  registry.registerProvider(name, provider, options);\n} catch (err) {\n  if (err.message.startsWith('Provider name must be')) {\n    throw new Error(`Invalid provider name \"${name}\" — check AI_PROVIDER config`);\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["validation","provider-registry","argument-error"],"backgroundTag":"invalid-argument-type","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}