mastra-ai/mastra · error

[Slack] Failed to resolve Mastra storage. Ensure your Mastra

Error message

[Slack] Failed to resolve Mastra storage. Ensure your Mastra instance has storage configured (e.g. LibSQLStore or PostgresStore). See https://mastra.ai/docs/storage

What it means

SlackProvider's #resolveStorage walks the attached Mastra instance looking for a configured storage backend (e.g. LibSQLStore or PostgresStore) or channel storage. If the lookup throws (e.g. the Mastra instance is present but storage access fails), it wraps the original error in this guidance message so developers know Slack requires persistent storage to track installations.

Source

Thrown at channels/slack/src/provider.ts:411

  async #resolveStorage(): Promise<ChannelsStorage> {
    // Try to get Mastra's channels storage
    if (this.#mastra) {
      try {
        const store = this.#mastra.getStorage?.();
        if (store) {
          // Ensure storage is initialized (creates tables if needed)
          await store.init();

          const channelsStorage = (await store.getStore('channels')) as ChannelsStorage | undefined;
          if (channelsStorage) {
            this.#storage = channelsStorage;
            this.#storageResolved = true;
            return this.#storage;
          }
        }
      } catch (err) {
        throw new Error(
          '[Slack] Failed to resolve Mastra storage. Ensure your Mastra instance has storage configured (e.g. LibSQLStore or PostgresStore). See https://mastra.ai/docs/storage',
          { cause: err },
        );
      }
    }

    throw new Error(
      '[Slack] No storage available. SlackProvider requires persistent storage, configure a storage backend on your Mastra instance. See https://mastra.ai/docs/storage',
    );
  }

  // ===========================================================================
  // Storage Helpers - Parse/serialize between ChannelInstallation and typed Slack data
  // ===========================================================================

  /**
   * Parse a ChannelInstallation record into a typed SlackInstallation.
   */

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Configure storage on your Mastra instance, e.g. new Mastra({ storage: new LibSQLStore({ url: 'file:./mastra.db' }) }).
  2. Check the 'cause' property of the thrown error to see the underlying storage failure and fix that (bad URL, permissions, driver missing).
  3. Verify the storage package is installed and the adapter constructor does not throw (test it standalone).

Example fix

// before
new Mastra({ agents });
// after
import { Mastra } from '@mastra/core';
import { LibSQLStore } from '@mastra/libsql';
new Mastra({ agents, storage: new LibSQLStore({ url: 'file:./mastra.db' }) });
Defensive patterns

Strategy: try-catch

Validate before calling

if (!mastra?.storage && !mastra?.channels?.storage) {
  throw new Error('Configure storage on your Mastra instance before using SlackProvider');
}

Type guard

function hasStorage(m: unknown): m is { storage: NonNullable<unknown> } {
  return typeof m === 'object' && m !== null && 'storage' in m && m.storage != null;
}

Try / catch

try {
  await provider.initialize();
} catch (err) {
  if (err instanceof Error && err.message.includes('Failed to resolve Mastra storage')) {
    console.error('storage error cause:', (err as { cause?: unknown }).cause);
    // fix the underlying storage adapter config
  } else throw err;
}

Prevention

When it happens

Trigger: Calling any SlackProvider operation that needs storage (installation lookup, connect, webhook handling) when resolving storage from the Mastra instance throws — e.g. the storage adapter fails to initialize or the mastra.channels/mastra storage surface throws during resolution.

Common situations: Mastra instance constructed without a storage option; storage adapter configured with a bad connection URL that throws on use; misconfigured DI so the provider cannot find storage on the instance.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/d73a5e96d194aadc. Report an issue: GitHub.