{"record":{"id":"208a7492f2d279a8","repo":"mastra-ai/mastra","slug":"message-deletion-is-not-supported-by-this-storage","errorCode":null,"errorMessage":"Message deletion is not supported by this storage adapter (${this.constructor.name}). The deleteMessages method needs to be implemented in the storage adapter.","messagePattern":"Message deletion is not supported by this storage adapter \\((.+?)\\)\\. The deleteMessages method needs to be implemented in the storage adapter\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/memory/base.ts","lineNumber":160,"sourceCode":"    throw new Error(\n      `Resource-scoped message listing is not implemented by this storage adapter (${this.constructor.name}). ` +\n        `Use an adapter that supports Observational Memory (pg, libsql, mongodb, convex) or disable observational memory.`,\n    );\n  }\n\n  abstract listMessagesById({ messageIds }: { messageIds: string[] }): Promise<{ messages: MastraDBMessage[] }>;\n\n  abstract saveMessages(args: { messages: MastraDBMessage[] }): Promise<{ messages: MastraDBMessage[] }>;\n\n  abstract updateMessages(args: {\n    messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {\n      id: string;\n      content?: { metadata?: MastraMessageContentV2['metadata']; content?: MastraMessageContentV2['content'] };\n    })[];\n  }): Promise<MastraDBMessage[]>;\n\n  async deleteMessages(_messageIds: string[]): Promise<void> {\n    throw new Error(\n      `Message deletion is not supported by this storage adapter (${this.constructor.name}). ` +\n        `The deleteMessages method needs to be implemented in the storage adapter.`,\n    );\n  }\n\n  /**\n   * List threads with optional filtering by resourceId and metadata.\n   *\n   * @param args - Filter, pagination, and ordering options\n   * @param args.filter - Optional filters for resourceId and/or metadata\n   * @param args.filter.resourceId - Optional resource ID to filter by\n   * @param args.filter.metadata - Optional metadata key-value pairs to filter by (AND logic)\n   * @returns Paginated list of threads matching the filters\n   */\n  abstract listThreads(args: StorageListThreadsInput): Promise<StorageListThreadsOutput>;\n\n  /**\n   * Clone a thread and its messages to create a new independent thread.","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/memory/base.ts#L142-L178","documentation":"deleteMessages is an adapter-provided capability; the base class default throws to signal the active storage adapter has not implemented message deletion. Deleting messages requires adapter-specific data manipulation the abstract base cannot perform.","triggerScenarios":"Calling deleteMessages(messageIds) on a storage adapter (or custom subclass) that doesn't override deleteMessages, e.g. memory message-deletion flows through the memory domain.","commonSituations":"Custom/minimal storage adapters; older adapters predating the deleteMessages API; tests using stub stores that don't implement deletion.","solutions":["Use or upgrade to a storage adapter that implements deleteMessages","Implement deleteMessages in your custom adapter","Skip/queue deletion and handle it in application code instead"],"exampleFix":"// before\nclass MyStore extends MastraStorage { /* no deleteMessages */ }\nawait storage.deleteMessages([id]); // throws\n// after\nclass MyStore extends MastraStorage {\n  async deleteMessages(messageIds: string[]): Promise<void> {\n    await this.db.run('DELETE FROM messages WHERE id IN (?)', messageIds);\n  }\n}","handlingStrategy":"fallback","validationCode":"function supportsDeleteMessages(storage: unknown): boolean {\n  return typeof (storage as any)?.deleteMessages === 'function' &&\n    (storage as any).deleteMessages !== (MastraStorage.prototype as any).deleteMessages;\n}","typeGuard":"function canDeleteMessages(s: unknown): s is { deleteMessages(ids: string[]): Promise<void> } {\n  return supportsDeleteMessages(s);\n}","tryCatchPattern":"try {\n  await storage.deleteMessages(ids);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Message deletion is not supported')) {\n    logger.warn('deleteMessages unsupported by adapter; queuing for later');\n    await deletionQueue.push(ids);\n    return;\n  }\n  throw e;\n}","preventionTips":["Verify the adapter implements deleteMessages before wiring deletion features","Keep custom adapters in sync with the MastraStorage base API surface","Use feature detection (and hide UI delete actions) when capability is missing"],"tags":["storage","unsupported-operation","memory"],"backgroundTag":"method-not-implemented-by-adapter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}