{"record":{"id":"6fd095d5eea2ab8d","repo":"mastra-ai/mastra","slug":"no-agent-or-agent-controller-found-with-id-agen","errorCode":null,"errorMessage":"No agent or agent controller found with id \"${agentId}\"","messagePattern":"No agent or agent controller found with id \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"channels/slack/src/provider.ts","lineNumber":1063,"sourceCode":"    const baseUrl = this.#getBaseUrl();\n    if (!baseUrl) {\n      throw new Error(\n        'SlackProvider baseUrl not set. Configure studioHost/studioProtocol/studioPort in Mastra server config, or call setBaseUrl().',\n      );\n    }\n\n    // In the agentId form, the agent must exist. In the options form the id may\n    // belong to a registered agent or an AgentController — resolve which one so\n    // the installation records who owns it.\n    const agent = this.#resolveAgent(agentId);\n    if (isAgentIdForm && !agent) {\n      throw new Error(`Agent \"${agentId}\" not found`);\n    }\n    let ownerType: SlackOwnerType = 'agent';\n    if (!isAgentIdForm && !agent) {\n      const controller = this.#resolveAgentController(agentId);\n      if (!controller) {\n        throw new Error(`No agent or agent controller found with id \"${agentId}\"`);\n      }\n      ownerType = 'agentController';\n    }\n\n    // If there's already a pending installation, return its authorization URL\n    // instead of creating a duplicate Slack app\n    const storage = await this.#getStorage();\n    const existingRecord = await storage.getInstallationByAgent(PLATFORM, agentId);\n    if (existingRecord?.status === 'pending') {\n      try {\n        const pending = this.#parsePendingInstallation(existingRecord);\n        const decrypted = this.#decryptPendingInstallation(pending);\n\n        // The stored Slack app may have been deleted out-of-band (e.g. removed\n        // from the Slack admin UI). Reusing its authorizationUrl would hand the\n        // caller a dead link (`Invalid client_id`). Probe existence first and,\n        // if the app is gone, drop the pending record and create a fresh app.\n        let appStillExists = true;","sourceCodeStart":1045,"sourceCodeEnd":1081,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/channels/slack/src/provider.ts#L1045-L1081","documentation":"In the object form connect({ id, name }), the id may belong to either a registered agent or an AgentController (since the agent may not exist yet). If #resolveAgent and #resolveAgentController both fail, the provider has no owner for the installation and throws this error.","triggerScenarios":"provider.connect({ id: 'x', name: 'Y' }) where 'x' matches neither a registered Agent nor a registered AgentController on the attached Mastra instance.","commonSituations":"Passing a made-up id intending the library to create an agent (it does not); controller not registered with Mastra; id from another environment; typos in the id.","solutions":["Register an AgentController with the given id on the Mastra instance, or use an id of an existing controller.","Use an existing registered agent's id with connect(agentId) instead.","Log/list available agents and controllers before connecting to pick a valid id."],"exampleFix":"// before\nawait provider.connect({ id: 'ghost-controller', name: 'Bot' });\n// after\nmastra.registerAgentController(new AgentController({ id: 'ghost-controller' }));\nawait provider.connect({ id: 'ghost-controller', name: 'Bot' });","handlingStrategy":"validation","validationCode":"const known = [...Object.keys(mastra.getAgents?.() ?? {}), ...listRegisteredControllerIds(mastra)];\nif (!known.includes(id)) {\n  throw new Error(`id \"${id}\" is neither an agent nor an agent controller`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await provider.connect({ id, name });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('No agent or agent controller found')) {\n    console.error('Register the agent or AgentController with this id before connecting');\n  } else throw err;\n}","preventionTips":["Only pass ids that already exist as agents or registered AgentControllers.","Keep controller registration in the same bootstrap file as SlackProvider setup.","Log registered ids at startup to catch mismatches early."],"tags":["validation","agents","slack"],"backgroundTag":"agent-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}