{"record":{"id":"3966e1a6c625e9e3","repo":"mastra-ai/mastra","slug":"no-slack-installation-found-for-agent-agentid","errorCode":null,"errorMessage":"No Slack installation found for agent \"${agentId}\"","messagePattern":"No Slack installation found for agent \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"channels/slack/src/provider.ts","lineNumber":1225,"sourceCode":"    return {\n      type: 'oauth' as const,\n      installationId,\n      authorizationUrl,\n    };\n  }\n\n  /**\n   * Disconnect an agent from Slack by deleting its app.\n   */\n  async disconnect(agentId: string): Promise<void> {\n    const client = this.#requireManifestClient();\n\n    const storage = await this.#getStorage();\n    const allRecords = await storage.listInstallations(PLATFORM);\n    const agentRecords = allRecords.filter(r => r.agentId === agentId);\n\n    if (agentRecords.length === 0) {\n      throw new Error(`No Slack installation found for agent \"${agentId}\"`);\n    }\n\n    for (const record of agentRecords) {\n      if (record.status === 'active') {\n        const installation = this.#decryptInstallation(this.#parseInstallation(record));\n\n        // Delete the app from Slack\n        try {\n          await client.deleteApp(installation.appId);\n        } catch (err) {\n          console.warn(`[Slack] Failed to delete Slack app ${installation.appId}:`, err);\n        }\n\n        // Remove adapter and command handlers\n        this.#adapters.delete(installation.id);\n        this.#slashCommands.delete(installation.webhookId);\n      }\n","sourceCodeStart":1207,"sourceCodeEnd":1243,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/channels/slack/src/provider.ts#L1207-L1243","documentation":"SlackProvider.listInstallations/getInstallation-style APIs look up stored installation records for a specific agentId. This error means storage returned records for the Slack platform but none had the requested agentId, so no Slack workspace has ever been connected for that agent. The library throws it instead of returning an empty/undefined installation so callers fail fast rather than acting on a missing connection.","triggerScenarios":"Calling a SlackProvider public API (e.g. getting an installation/credentials for an agent) with an agentId that has zero installation records in storage; agentId typo or an agent created after the Slack app was installed under a different agentId.","commonSituations":"Renaming or recreating an agent and forgetting to re-install the Slack app for the new agentId; querying the wrong storage backend (dev DB vs prod); passing a Mastra agent name where the recorded agentId is its ID.","solutions":["List all installations via storage.listInstallations(PLATFORM) and confirm the exact agentId stored on the records.","Install the Slack app for the correct agent (complete the OAuth flow) so an installation record with that agentId exists.","Fix the agentId being passed in — match it exactly to the one used during installation.","Point the provider at the storage backend that actually contains the installation."],"exampleFix":"// before\nconst installation = await provider.getInstallation('support-agent');\n// after\nconst records = await storage.listInstallations(PLATFORM);\nconst match = records.find(r => r.agentId === 'support-agent');\nif (!match) {\n  await provider.install({ agentId: 'support-agent' }); // run OAuth first\n}","handlingStrategy":"validation","validationCode":"const records = await storage.listInstallations('slack');\nif (!records.some(r => r.agentId === agentId)) {\n  throw new Error(`Slack not installed for agent ${agentId}; run the install flow first`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const installation = await provider.getInstallation(agentId);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('No Slack installation found')) {\n    await startSlackInstallFlow(agentId); // kick off OAuth\n  } else throw e;\n}","preventionTips":["Store the agentId used at install time alongside the agent and reuse it verbatim.","List installations at startup and log any agents without a Slack connection.","Keep dev/prod storage backends consistent to avoid 'missing install' surprises."],"tags":["slack","oauth","not-found","configuration"],"backgroundTag":"installation-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}