{"record":{"id":"f61303b1ecbd6a22","repo":"ruvnet/ruflo","slug":"model-is-required-for-this-name-provider","errorCode":null,"errorMessage":"Model is required for ${this.name} provider","messagePattern":"Model is required for (.+?) provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/providers/src/base-provider.ts","lineNumber":194,"sourceCode":"    if (this.config.enableCaching) {\n      this.startHealthChecks();\n    }\n\n    // Initial health check\n    await this.healthCheck();\n  }\n\n  /**\n   * Provider-specific initialization (override in subclass)\n   */\n  protected abstract doInitialize(): Promise<void>;\n\n  /**\n   * Validate provider configuration\n   */\n  protected validateConfig(): void {\n    if (!this.config.model) {\n      throw new Error(`Model is required for ${this.name} provider`);\n    }\n\n    if (!this.validateModel(this.config.model)) {\n      this.logger.warn(`Model ${this.config.model} may not be supported by ${this.name}`);\n    }\n\n    if (this.config.temperature !== undefined) {\n      if (this.config.temperature < 0 || this.config.temperature > 2) {\n        throw new Error('Temperature must be between 0 and 2');\n      }\n    }\n  }\n\n  /**\n   * Complete a request\n   */\n  async complete(request: LLMRequest): Promise<LLMResponse> {\n    const startTime = Date.now();","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/providers/src/base-provider.ts#L176-L212","documentation":"BaseProvider.initialize() runs validateConfig() before any network call; if the provider config has no `model`, this error is thrown at startup. The model selects which LLM every request uses (e.g. 'gpt-4o', 'claude-sonnet-4'), so it is mandatory for all providers.","triggerScenarios":"Constructing and initializing any provider with a config whose `model` is missing, undefined or empty - e.g. new OpenAIProvider({ name: 'openai', config: { apiKey } }) with no model, or model read from an unset env var.","commonSituations":"Model sourced from an unset OPENAI_MODEL / ANTHROPIC_MODEL env var; using `modelId` or `modelName` instead of `model`; a config merge/spread that overwrites model with undefined; scaffolding copied from an example that omitted the field.","solutions":["Add `model` to the provider config: config: { apiKey, model: 'gpt-4o' }","If the model comes from an env var, verify it is actually exported in the shell/.env the process loads (printenv | grep MODEL)","Default it early - model: process.env.OPENAI_MODEL ?? 'gpt-4o-mini' - so a missing env var can never reach the provider","Type your config as the package's LLMProviderConfig so TypeScript flags the missing field before runtime"],"exampleFix":"// before\nconst provider = new OpenAIProvider({\n  name: 'openai',\n  config: { apiKey: process.env.OPENAI_API_KEY }, // no model -> throws at initialize()\n});\nawait provider.initialize();\n\n// after\nconst provider = new OpenAIProvider({\n  name: 'openai',\n  config: {\n    apiKey: process.env.OPENAI_API_KEY,\n    model: process.env.OPENAI_MODEL ?? 'gpt-4o',\n  },\n});\nawait provider.initialize();","handlingStrategy":"validation","validationCode":"function assertValidProviderConfig(config: LLMProviderConfig): void {\n  if (!config.model || typeof config.model !== 'string') {\n    throw new Error(`Missing required config.model for provider '${config.provider}'`);\n  }\n}","typeGuard":"interface ConfigWithModel extends LLMProviderConfig { model: string }\nfunction hasModel(cfg: LLMProviderConfig): cfg is ConfigWithModel {\n  return typeof cfg.model === 'string' && cfg.model.length > 0;\n}","tryCatchPattern":"try {\n  await provider.initialize();\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Model is required')) {\n    // config bug: surface immediately, do not retry\n    throw new ConfigError('provider config missing model', { cause: e });\n  }\n  throw e;\n}","preventionTips":["Type config objects as LLMProviderConfig so missing fields fail at compile time","Apply env-derived values through a default (?? 'gpt-4o-mini') instead of passing raw","Run a startup config assertion before initializing any provider"],"tags":["config","validation","initialization","startup"],"backgroundTag":"missing-required-config","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}