{"record":{"id":"bf72366b50e3244a","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"embeddingservice-baseurl-is-required-for-remote-p","errorCode":null,"errorMessage":"EmbeddingService: baseUrl is required for remote provider","messagePattern":"EmbeddingService: baseUrl is required for remote provider","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"MemoryCore/src/core/store/embedding.ts","lineNumber":419,"sourceCode":"\nexport class OpenAIEmbeddingService implements EmbeddingService {\n  private readonly baseUrl: string;\n  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  }","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/core/store/embedding.ts#L401-L437","documentation":"The remote (OpenAI-compatible) EmbeddingService requires a baseUrl pointing at the embedding HTTP endpoint. Without it no requests can be issued, so the constructor throws immediately. This is fail-fast validation of OpenAIEmbeddingConfig.","triggerScenarios":"`new EmbeddingService(config)` where config.apiKey is present but config.baseUrl is undefined, null, or empty.","commonSituations":"Config built programmatically with only apiKey/model set, migration from a library version where baseUrl had a default, or loading a config file that omitted the baseUrl field.","solutions":["Set config.baseUrl to the provider endpoint (e.g. https://api.openai.com/v1), with or without a trailing slash (trailing slashes are stripped)","Verify the config file/plugin settings actually populate tcvdb/embedding baseUrl before construction","Use the provider's documented base URL for the embedding API version you target"],"exampleFix":"// before\nnew EmbeddingService({ apiKey: key, model: 'text-embedding-3-small', dimensions: 1536 })\n// after\nnew EmbeddingService({ apiKey: key, baseUrl: 'https://api.openai.com/v1', model: 'text-embedding-3-small', dimensions: 1536 })","handlingStrategy":"validation","validationCode":"function assertBaseUrl(cfg) {\n  const url = cfg?.baseUrl;\n  if (!url || typeof url !== 'string' || !url.trim()) throw new Error('baseUrl is required');\n  new URL(url);\n  return cfg;\n}\nassertBaseUrl(config);","typeGuard":"function hasBaseUrl(cfg): cfg is OpenAIEmbeddingConfig & { baseUrl: string } {\n  return typeof cfg?.baseUrl === 'string' && cfg.baseUrl.trim().length > 0;\n}","tryCatchPattern":"try {\n  svc = new EmbeddingService(config, logger);\n} catch (e) {\n  if (String(e.message).includes('baseUrl is required')) {\n    throw new ConfigError('Embedding baseUrl missing — set it to e.g. https://api.openai.com/v1');\n  }\n  throw e;\n}","preventionTips":["Keep all provider endpoint URLs in one config module with defaults","Validate the full OpenAIEmbeddingConfig once at startup, not ad hoc","Document required fields in the config schema (JSON schema/zod)"],"tags":["configuration","constructor","embedding","missing-url"],"backgroundTag":"missing-config-field","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}