FlowiseAI/Flowise · warning · InternalFlowiseError

Error: assistantsController.createAssistant - body not provi

Error message

Error: assistantsController.createAssistant - body not provided!

What it means

Thrown by assistantsController.createAssistant with HTTP 412 when req.body is falsy. The handler is mounted at POST /api/v1/assistants (routes/assistants/index.ts:8). req.body is undefined when no body parser populated it — typically because the request lacked a Content-Type: application/json header or sent an empty body that the JSON parser did not materialize into an object.

Source

Thrown at packages/server/src/controllers/assistants/index.ts:12

import { NextFunction, Request, Response } from 'express'
import { StatusCodes } from 'http-status-codes'
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
import { AssistantType } from '../../Interface'
import assistantsService from '../../services/assistants'
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
import { checkUsageLimit } from '../../utils/quotaUsage'

const createAssistant = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (!req.body) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,
                `Error: assistantsController.createAssistant - body not provided!`
            )
        }
        const body = req.body
        const orgId = req.user?.activeOrganizationId
        if (!orgId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: assistantsController.createAssistant - organization ${orgId} not found!`
            )
        }
        const workspaceId = req.user?.activeWorkspaceId
        if (!workspaceId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: assistantsController.createAssistant - workspace ${workspaceId} not found!`
            )

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Send a JSON body with Content-Type: application/json on POST /api/v1/assistants.
  2. Ensure the body is a non-empty object (it must later carry at least a 'type' field used downstream).
  3. Confirm express.json() (or the equivalent body parser) is mounted before the v1 router in src/index.ts.

Example fix

// before
await fetch(`${BASE}/api/v1/assistants`, { method: 'POST', headers: authHeaders })

// after
await fetch(`${BASE}/api/v1/assistants`, {
  method: 'POST',
  headers: { ...authHeaders, 'Content-Type': 'application/json' },
  body: JSON.stringify({ type: 'CHATFLOW', name: 'My Assistant' })
})
Defensive patterns

Strategy: validation

Validate before calling

function buildCreateAssistant(body: unknown) {
  if (!body || typeof body !== 'object') {
    throw new Error('createAssistant requires a JSON body')
  }
  return fetch(`${BASE}/api/v1/assistants`, {
    method: 'POST',
    headers: { ...authHeaders, 'Content-Type': 'application/json' },
    body: JSON.stringify(body)
  })
}

Type guard

const isJsonObject = (b: unknown): b is Record<string, unknown> =>
  !!b && typeof b === 'object' && !Array.isArray(b)

Prevention

When it happens

Trigger: POST /api/v1/assistants with no body, with an empty body, or with a Content-Type other than application/json (so express.json() skips parsing and leaves req.body undefined). A curl without -d/--data, or a fetch with no body and no content-type.

Common situations: Client forgot to set Content-Type: application/json. A proxy rewriting/stripping the Content-Type. A bug where the request body is serialized conditionally and omitted for a new/default assistant. express.json() middleware not registered or registered after this router.

Related errors


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