{"record":{"id":"bceb6377cd8d8b11","repo":"mastra-ai/mastra","slug":"name-id-must-be-provided-and-cannot-be-empty","errorCode":null,"errorMessage":"${name}: id must be provided and cannot be empty.","messagePattern":"(.+?): id must be provided and cannot be empty\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/base.ts","lineNumber":375,"sourceCode":"   * `prune()`. Undefined means nothing is pruned (keep forever).\n   */\n  protected retention?: RetentionConfig;\n\n  /**\n   * Retained references to the parent stores supplied via composition. `init()`\n   * delegates to these so the parent's own `init()` logic (pragmas, ordered\n   * DDL, init coalescing, etc.) runs instead of being bypassed by the\n   * composite iterating the inner domains in parallel — which was the cause\n   * of the SQLITE_BUSY / \"no such table\" races reported in issue #16782.\n   */\n  protected parentDefault?: MastraCompositeStore;\n  protected parentEditor?: MastraCompositeStore;\n\n  constructor(config: MastraCompositeStoreConfig) {\n    const name = config.name ?? 'MastraCompositeStore';\n\n    if (!config.id || typeof config.id !== 'string' || config.id.trim() === '') {\n      throw new Error(`${name}: id must be provided and cannot be empty.`);\n    }\n\n    super({\n      component: 'STORAGE',\n      name,\n    });\n\n    this.id = config.id;\n    this.disableInit = config.disableInit ?? false;\n    this.retention = config.retention;\n\n    // If composition config is provided (default, editor, or domains), compose the stores\n    if (config.default || config.editor || config.domains) {\n      const defaultStores = config.default?.stores;\n      const editorStores = config.editor?.stores;\n      const domainOverrides = config.domains ?? {};\n\n      // Retain the parent store refs so init() can delegate to their own","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/base.ts#L357-L393","documentation":"MastraCompositeStore requires a non-empty string `id` in its config. The constructor validates it immediately and throws if it is missing, not a string, or whitespace-only. This guarantees every composite store has a stable identifier.","triggerScenarios":"Calling `new MastraCompositeStore({ name })` or any subclass constructor without `config.id`, passing `id: ''`, a non-string (number, undefined), or a string of only whitespace like `'   '`.","commonSituations":"Migrating from older store configs where `id` was optional; building the config object dynamically and leaving `id` unset; trimming user-supplied IDs that turn out to be empty; typos like `Id` vs `id`.","solutions":["Pass a non-empty string `id` in the MastraCompositeStore config","If the ID comes from user input or env, trim it and check truthiness before constructing","Check for property-name typos (e.g. `Id`, `key`) so the real `id` field isn't left undefined"],"exampleFix":"// before\nnew MastraCompositeStore({ name: 'MyStore' });\n// after\nnew MastraCompositeStore({ name: 'MyStore', id: 'my-store' });","handlingStrategy":"validation","validationCode":"function assertValidStoreId(id: unknown): asserts id is string {\n  if (typeof id !== 'string' || id.trim() === '') {\n    throw new Error('MastraCompositeStore id must be a non-empty string');\n  }\n}\nassertValidStoreId(config.id);","typeGuard":"function hasStoreId(config: { id?: unknown }): config is { id: string } {\n  return typeof config.id === 'string' && config.id.trim() !== '';\n}","tryCatchPattern":"try {\n  const store = new MastraCompositeStore(config);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('id must be provided')) {\n    throw new Error(`Invalid store config: ${config.name ?? 'unnamed'} is missing a non-empty id`);\n  }\n  throw e;\n}","preventionTips":["Always set a unique, non-empty string id in composite store configs","Trim user/env-supplied IDs before passing them in","Centralize store construction in one factory that validates config","Type the config with a required `id: string` field so TypeScript catches omissions"],"tags":["storage","configuration","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}