FlowiseAI/Flowise · error · Error

Team ID is required to list channels

Error message

Team ID is required to list channels

What it means

Thrown synchronously by ListChannelsTool._call when teamId is falsy after merging the tool args with defaultParams. Because the throw sits above the try block at core.ts:101, it propagates out of _call as a real rejection rather than being converted into a formatResponse error string. The schema at core.ts:86 declares teamId as z.string() (non-optional), so a well-behaved zod-validated caller cannot trigger this — it fires only when defaultParams overrides teamId to undefined, when the schema is bypassed, or when an LLM agent sends malformed tool input.

Source

Thrown at packages/components/nodes/tools/MicrosoftTeams/core.ts:102

            description: 'List all channels in a team',
            schema: z.object({
                teamId: z.string().describe('ID of the team to list channels from'),
                maxResults: z.number().optional().default(50).describe('Maximum number of channels to return')
            }),
            baseUrl: BASE_URL,
            method: 'GET',
            headers: {}
        }

        super({ ...toolInput, accessToken: args.accessToken, defaultParams: args.defaultParams })
    }

    protected async _call(arg: any): Promise<string> {
        const params = { ...arg, ...this.defaultParams }
        const { teamId, maxResults = 50 } = params

        if (!teamId) {
            throw new Error('Team ID is required to list channels')
        }

        try {
            const endpoint = `/teams/${teamId}/channels`
            const result = await this.makeTeamsRequest(endpoint)

            // Filter results to maxResults on client side since $top is not supported
            const channels = result.value || []
            const limitedChannels = channels.slice(0, maxResults)

            const responseData = {
                success: true,
                channels: limitedChannels,
                count: limitedChannels.length,
                total: channels.length
            }

            return this.formatResponse(responseData, params)

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Confirm the tool input includes a non-empty teamId string before invoking.
  2. Fix defaultParams semantics: the spread { ...arg, ...this.defaultParams } means defaultParams WINS — invert to { ...this.defaultParams, ...arg } so caller args take precedence, or stop putting teamId in defaultParams.
  3. If you genuinely want a default team, put it in defaultParams but ensure the caller omits teamId rather than passing undefined.
  4. Wrap the call site in try/catch since this throw escapes the tool.

Example fix

// before — defaultParams silently overrides caller
const params = { ...arg, ...this.defaultParams } // defaultParams wins

// after — caller args win, defaults only fill gaps
const params = { ...this.defaultParams, ...arg }
Defensive patterns

Strategy: validation

Validate before calling

function validateListChannelsInput(input: unknown): asserts input is { teamId: string } {
  if (typeof input !== 'object' || input === null) throw new Error('input required')
  const { teamId } = input as any
  if (typeof teamId !== 'string' || !teamId.trim()) {
    throw new Error('teamId is required and must be a non-empty string')
  }
}

Type guard

function isListChannelsArgs(x: unknown): x is { teamId: string; maxResults?: number } {
  return typeof x === 'object' && x !== null &&
    typeof (x as any).teamId === 'string' && (x as any).teamId.trim() !== ''
}

Try / catch

try {
  if (!isListChannelsArgs(input)) {
    return { error: 'teamId required' }
  }
  return await listChannelsTool.invoke(input)
} catch (e) {
  // validation throws above escape the tool — handle at orchestration
  log.warn('list_channels validation failed', { error: e })
  return { error: (e as Error).message }
}

Prevention

When it happens

Trigger: Caller invokes list_channels without teamId; defaultParams contains { teamId: undefined } which overwrites the arg via the { ...arg, ...this.defaultParams } spread at core.ts:98; LangChain agent bypasses zod parsing; the tool is invoked directly in tests with an empty object.

Common situations: defaultParams set globally with teamId: '' or undefined intended as 'use agent value' but actually clobbering it; agent prompt not telling the model teamId is required; CI test that constructs the tool and calls _call({}) directly.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/2c9f50a792c340ac. Report an issue: GitHub.