{"record":{"id":"d5c3f29ab6cfda74","repo":"mastra-ai/mastra","slug":"connect-id-name-name-is-required-when-con","errorCode":null,"errorMessage":"connect({ id, name }): \"name\" is required when connecting without an agent id","messagePattern":"connect\\((.+?)\\): \"name\" is required when connecting without an agent id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"channels/slack/src/provider.ts","lineNumber":1040,"sourceCode":"   */\n  async connect(agentId: string, options?: SlackConnectOptions): Promise<ChannelConnectResult>;\n  /**\n   * Connect to Slack by creating a new Slack app for an arbitrary connection id\n   * (no registered agent required — e.g. an AgentController or custom owner).\n   * Since there is no agent to derive a display name from, `name` is required.\n   *\n   * @returns OAuth connect result with authorization URL for user redirect\n   */\n  async connect(options: SlackConnectOptions & { id: string; name: string }): Promise<ChannelConnectResult>;\n  async connect(\n    agentIdOrOptions: string | (SlackConnectOptions & { id: string; name: string }),\n    maybeOptions?: SlackConnectOptions,\n  ): Promise<ChannelConnectResult> {\n    const isAgentIdForm = typeof agentIdOrOptions === 'string';\n    const agentId = isAgentIdForm ? agentIdOrOptions : agentIdOrOptions.id;\n    const options = isAgentIdForm ? maybeOptions : agentIdOrOptions;\n    if (!isAgentIdForm && !agentIdOrOptions.name) {\n      throw new Error('connect({ id, name }): \"name\" is required when connecting without an agent id');\n    }\n\n    const client = this.#requireManifestClient();\n\n    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    }","sourceCodeStart":1022,"sourceCodeEnd":1058,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/channels/slack/src/provider.ts#L1022-L1058","documentation":"connect() supports two forms: connect(agentId, options?) and connect({ id, name }). When using the object form without an agent id already known to Mastra (id provided but no name), the library requires a \"name\" because it creates/identifies the Slack app and needs a display name for the new agent binding.","triggerScenarios":"Calling provider.connect({ id: 'some-id' }) (object form) with no name property and where the id is not resolved as an existing agent — the guard fires whenever the object form is used without a name.","commonSituations":"Migrating from the string form connect(agentId) to the options form and forgetting name; dynamically building the options object and omitting name; typing errors where the object form was intended for a new agent.","solutions":["Pass a name in the options object: connect({ id, name: 'My Slack Agent' }).","If connecting an existing registered agent, use the string form: connect(agentId, options?).","Add runtime validation before calling connect to ensure either a string agentId or both id and name are provided."],"exampleFix":"// before\nawait provider.connect({ id: 'agent-123' });\n// after\nawait provider.connect({ id: 'agent-123', name: 'Support Agent' });","handlingStrategy":"validation","validationCode":"function assertValidConnectArgs(agentIdOrOptions, maybeOptions) {\n  if (typeof agentIdOrOptions === 'string') return;\n  if (!agentIdOrOptions?.name) {\n    throw new Error('object form requires { id, name }');\n  }\n}","typeGuard":"function isOptionsForm(x: unknown): x is { id: string; name: string } {\n  return typeof x === 'object' && x !== null && 'id' in x && 'name' in x && typeof (x as any).name === 'string' && (x as any).name.length > 0;\n}","tryCatchPattern":"try {\n  await provider.connect({ id });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('\"name\" is required')) {\n    await provider.connect({ id, name: deriveNameFromId(id) });\n  } else throw err;\n}","preventionTips":["Prefer the string form connect(agentId) for existing registered agents.","Centralize connect calls in a helper that enforces the { id, name } shape.","Type your call sites with a discriminated union of the two connect forms."],"tags":["validation","api-misuse","slack"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}