{"record":{"id":"54fa234f77c7a7d2","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"embeddingservice-model-is-required-for-remote-pro","errorCode":null,"errorMessage":"EmbeddingService: model is required for remote provider","messagePattern":"EmbeddingService: model is required for remote provider","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"MemoryCore/src/core/store/embedding.ts","lineNumber":422,"sourceCode":"  private readonly apiKey: string;\n  private readonly model: string;\n  private readonly dims: number;\n  private readonly sendDimensions: boolean;\n  private readonly providerName: string;\n  private readonly proxyUrl?: string;\n  private readonly maxInputChars?: number;\n  private readonly timeoutMs: number;\n  private readonly logger?: Logger;\n\n  constructor(config: OpenAIEmbeddingConfig, logger?: Logger) {\n    if (!config.apiKey) {\n      throw new Error(\"EmbeddingService: apiKey is required for remote provider\");\n    }\n    if (!config.baseUrl) {\n      throw new Error(\"EmbeddingService: baseUrl is required for remote provider\");\n    }\n    if (!config.model) {\n      throw new Error(\"EmbeddingService: model is required for remote provider\");\n    }\n    if (!config.dimensions || config.dimensions <= 0) {\n      throw new Error(\"EmbeddingService: dimensions is required for remote provider (must be a positive integer)\");\n    }\n    this.baseUrl = config.baseUrl.replace(/\\/+$/, \"\");\n    this.apiKey = config.apiKey;\n    this.model = config.model;\n    this.dims = config.dimensions;\n    this.sendDimensions = config.sendDimensions ?? true;\n    this.providerName = config.provider || \"openai\";\n    this.proxyUrl = config.proxyUrl?.trim() || undefined;\n    this.maxInputChars = config.maxInputChars && config.maxInputChars > 0 ? config.maxInputChars : undefined;\n    this.timeoutMs = config.timeoutMs && config.timeoutMs > 0 ? config.timeoutMs : DEFAULT_API_TIMEOUT_MS;\n    this.logger = logger;\n  }\n\n  getDimensions(): number {\n    return this.dims;","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/core/store/embedding.ts#L404-L440","documentation":"Remote embedding requests must name the embedding model to request from the API. The constructor throws this error when config.model is falsy so that misconfiguration is caught before any network call.","triggerScenarios":"`new EmbeddingService(config)` with apiKey and baseUrl set but config.model undefined, null, or empty string.","commonSituations":"Typo like 'models' in the config object, config sourced from JSON with the model field missing, or copying a local-provider config (which may not need a model name) into the remote constructor.","solutions":["Set config.model to a valid embedding model (e.g. 'text-embedding-3-small')","Ensure config.dimensions matches the chosen model's output dimensions","Re-read the plugin/config file to confirm the model field is present"],"exampleFix":"// before\nnew EmbeddingService({ apiKey: key, baseUrl: 'https://api.openai.com/v1', dimensions: 1536 })\n// after\nnew EmbeddingService({ apiKey: key, baseUrl: 'https://api.openai.com/v1', model: 'text-embedding-3-small', dimensions: 1536 })","handlingStrategy":"validation","validationCode":"if (!config?.model || !String(config.model).trim()) {\n  throw new Error('embedding model is required (e.g. text-embedding-3-small)');\n}","typeGuard":"function hasModel(cfg): cfg is OpenAIEmbeddingConfig & { model: string } {\n  return typeof cfg?.model === 'string' && cfg.model.trim().length > 0;\n}","tryCatchPattern":"try {\n  svc = new EmbeddingService(config, logger);\n} catch (e) {\n  if (String(e.message).includes('model is required')) {\n    throw new ConfigError('Embedding model not configured');\n  }\n  throw e;\n}","preventionTips":["Centralize model defaults in config so the field is never absent","Add config schema validation (zod/JSON schema) at load time","Test config loading in CI with the production config file"],"tags":["configuration","constructor","embedding"],"backgroundTag":"missing-config-field","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}