{"record":{"id":"a5175739a5c112c3","repo":"eyaltoledano/claude-task-master","slug":"baseaiprovider-cannot-be-instantiated-directly","errorCode":null,"errorMessage":"BaseAIProvider cannot be instantiated directly","messagePattern":"BaseAIProvider cannot be instantiated directly","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/ai-providers/base-provider.js","lineNumber":130,"sourceCode":"\t\treturn baseSchema;\n\t}\n\n\tconst sanitizedSchema = sanitizeIntegerConstraints(baseSchema.jsonSchema);\n\n\tif (typeof jsonSchemaHelper === 'function') {\n\t\treturn jsonSchemaHelper(sanitizedSchema, { validate: baseSchema.validate });\n\t}\n\n\treturn { ...baseSchema, jsonSchema: sanitizedSchema };\n};\n\n/**\n * Base class for all AI providers\n */\nexport class BaseAIProvider {\n\tconstructor() {\n\t\tif (this.constructor === BaseAIProvider) {\n\t\t\tthrow new Error('BaseAIProvider cannot be instantiated directly');\n\t\t}\n\n\t\t// Each provider must set their name\n\t\tthis.name = this.constructor.name;\n\n\t\t// Cache proxy agent to avoid creating multiple instances\n\t\tthis._proxyAgent = null;\n\n\t\t/**\n\t\t * Whether this provider needs explicit schema in JSON mode\n\t\t * Can be overridden by subclasses\n\t\t * @type {boolean}\n\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","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/ai-providers/base-provider.js#L112-L148","documentation":"BaseAIProvider is an abstract base class for all AI providers. Instantiating it directly is a programming error because it has no provider implementation (no API client, no name semantics beyond the class name), so the constructor throws to enforce subclassing.","triggerScenarios":"Executing `new BaseAIProvider()` directly instead of instantiating a concrete provider subclass (e.g., new AzureProvider(), new OpenAIProvider()).","commonSituations":"Dynamic provider resolution falling back to the base class; typos in provider class names; tests or factories instantiating the wrong class.","solutions":["Instantiate a concrete provider class that extends BaseAIProvider","Check your provider factory/registry maps names to actual provider classes","In tests, create a minimal subclass for testing base behavior"],"exampleFix":"// before\nconst provider = new BaseAIProvider();\n// after\nimport { AzureProvider } from './azure.js';\nconst provider = new AzureProvider();","handlingStrategy":"type-guard","validationCode":"if (ProviderClass === BaseAIProvider) throw new Error('Use a concrete provider subclass');","typeGuard":"function isConcreteProvider(Cls) { return typeof Cls === 'function' && Cls !== BaseAIProvider && Cls.prototype instanceof BaseAIProvider; }","tryCatchPattern":"try {\n  const provider = new ProviderClass();\n} catch (err) {\n  if (err.message.includes('cannot be instantiated directly')) {\n    console.error('Resolve a concrete provider class from the provider registry');\n  } else throw err;\n}","preventionTips":["Use the provider factory/registry rather than instantiating classes directly","Map provider name strings to classes with a lookup table with a safe default","In tests, subclass BaseAIProvider to test base behavior"],"tags":["abstract-class","instantiation","provider","architecture"],"backgroundTag":"abstract-class-instantiation","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}