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
- Send a JSON body with Content-Type: application/json on POST /api/v1/assistants.
- Ensure the body is a non-empty object (it must later carry at least a 'type' field used downstream).
- 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
- Always send Content-Type: application/json for POST/PUT to Flowise.
- Centralize POST/PUT calls behind a helper that forces the JSON content type and a non-empty body.
- Confirm express.json() is mounted before the v1 router.
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
- Error: assistantsController.updateAssistant - body not provi
- Error: assistantsController.generateAssistantInstruction - b
- Error: assistantsController.deleteAssistant - id not provide
- Error: assistantsController.getAssistantById - id not provid
- Error: assistantsController.updateAssistant - id not provide
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/9bd1d4fa8f41961e.
Report an issue: GitHub.