{"record":{"id":"d067d6fd410ce67e","repo":"mastra-ai/mastra","slug":"vector-invalid-id","errorCode":"VECTOR_INVALID_ID","errorMessage":"Vector id must be provided and cannot be empty","messagePattern":"Vector id must be provided and cannot be empty","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/vector/vector.ts","lineNumber":78,"sourceCode":"/**\n * Type guard to check if an embedding model is a supported modern version (V2 or V3).\n * Use embedV2 for V2 models, embedV3 for V3 models, and embedV1 for legacy V1 models.\n */\nexport const isSupportedEmbeddingModel = <T>(\n  model: MastraEmbeddingModel<T>,\n): model is MastraSupportedEmbeddingModel<T> => {\n  return supportedEmbeddingModelSpecifications.includes(\n    model.specificationVersion as (typeof supportedEmbeddingModelSpecifications)[number],\n  );\n};\n\nexport abstract class MastraVector<Filter = VectorFilter> extends MastraBase {\n  id: string;\n  disableInit: boolean = false;\n\n  constructor({ id, disableInit }: { id: string; disableInit?: boolean }) {\n    if (!id || typeof id !== 'string' || id.trim() === '') {\n      throw new MastraError({\n        id: 'VECTOR_INVALID_ID',\n        text: 'Vector id must be provided and cannot be empty',\n        domain: ErrorDomain.MASTRA_VECTOR,\n        category: ErrorCategory.USER,\n      });\n    }\n    super({ name: 'MastraVector', component: 'VECTOR' });\n    this.id = id;\n    this.disableInit = disableInit ?? false;\n  }\n\n  get indexSeparator(): string {\n    return '_';\n  }\n\n  abstract query(params: QueryVectorParams<Filter>): Promise<QueryResult[]>;\n  // Adds type checks for positional arguments if used\n  abstract upsert(params: UpsertVectorParams): Promise<string[]>;","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/vector/vector.ts#L60-L96","documentation":"The MastraVector base-class constructor requires a non-empty string id identifying the store instance. Passing a missing, non-string, or whitespace-only id is treated as a configuration error and throws immediately at instantiation.","triggerScenarios":"new MyVectorStore({ id: '' }), forgetting the id option entirely, passing id from an unset env/config variable, or passing a non-string (number/symbol).","commonSituations":"Reading id from process.env that was never set; template config spread that drops the id; renaming a config key so id falls through as undefined.","solutions":["Pass a non-empty string id: new PgVector({ id: 'pg-main', connectionString })","Check the config source — log or assert the id value before construction","Give a literal default id instead of an env-derived one when unsure"],"exampleFix":"// before\nconst store = new PgVector({ id: process.env.VECTOR_ID, connectionString });\n// after\nconst store = new PgVector({ id: process.env.VECTOR_ID || 'pg-main', connectionString });","handlingStrategy":"validation","validationCode":"function assertStoreId(id: unknown): asserts id is string {\n  if (typeof id !== 'string' || id.trim() === '') throw new Error('vector store id required');\n}","typeGuard":"function isValidStoreId(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  const store = new PgVector({ id, connectionString });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'VECTOR_INVALID_ID') {\n    throw new Error('VECTOR_ID config missing — set a non-empty store id');\n  }\n  throw e;\n}","preventionTips":["Use a literal default id instead of raw env vars when possible","Validate config object shape with a schema (zod) before constructing stores","Never spread configs where the id key may be dropped"],"tags":["configuration","vector-store","constructor"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}