{"record":{"id":"9bd1d4fa8f41961e","repo":"FlowiseAI/Flowise","slug":"error-assistantscontroller-createassistant-body","errorCode":null,"errorMessage":"Error: assistantsController.createAssistant - body not provided!","messagePattern":"Error: assistantsController\\.createAssistant - body not provided!","errorType":"validation","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"warning","filePath":"packages/server/src/controllers/assistants/index.ts","lineNumber":12,"sourceCode":"import { NextFunction, Request, Response } from 'express'\nimport { StatusCodes } from 'http-status-codes'\nimport { InternalFlowiseError } from '../../errors/internalFlowiseError'\nimport { AssistantType } from '../../Interface'\nimport assistantsService from '../../services/assistants'\nimport { getRunningExpressApp } from '../../utils/getRunningExpressApp'\nimport { checkUsageLimit } from '../../utils/quotaUsage'\n\nconst createAssistant = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (!req.body) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: assistantsController.createAssistant - body not provided!`\n            )\n        }\n        const body = req.body\n        const orgId = req.user?.activeOrganizationId\n        if (!orgId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: assistantsController.createAssistant - organization ${orgId} not found!`\n            )\n        }\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: assistantsController.createAssistant - workspace ${workspaceId} not found!`\n            )","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/assistants/index.ts#L1-L30","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait fetch(`${BASE}/api/v1/assistants`, { method: 'POST', headers: authHeaders })\n\n// after\nawait fetch(`${BASE}/api/v1/assistants`, {\n  method: 'POST',\n  headers: { ...authHeaders, 'Content-Type': 'application/json' },\n  body: JSON.stringify({ type: 'CHATFLOW', name: 'My Assistant' })\n})","handlingStrategy":"validation","validationCode":"function buildCreateAssistant(body: unknown) {\n  if (!body || typeof body !== 'object') {\n    throw new Error('createAssistant requires a JSON body')\n  }\n  return fetch(`${BASE}/api/v1/assistants`, {\n    method: 'POST',\n    headers: { ...authHeaders, 'Content-Type': 'application/json' },\n    body: JSON.stringify(body)\n  })\n}","typeGuard":"const isJsonObject = (b: unknown): b is Record<string, unknown> =>\n  !!b && typeof b === 'object' && !Array.isArray(b)","tryCatchPattern":null,"preventionTips":["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."],"tags":["validation","express","request-body","precondition-failed","flowise","assistants"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}