{"record":{"id":"cd8e481fa5bbedb5","repo":"FlowiseAI/Flowise","slug":"error-chatmessagescontroller-createchatmessage","errorCode":null,"errorMessage":"Error: chatMessagesController.createChatMessage - request body not provided!","messagePattern":"Error: chatMessagesController\\.createChatMessage - request body not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"info","filePath":"packages/server/src/controllers/chat-messages/index.ts","lineNumber":39,"sourceCode":"        ) {\n            feedbackTypeFilters = [ChatMessageRatingType.THUMBS_UP, ChatMessageRatingType.THUMBS_DOWN]\n        } else if (feedbackTypeFilterArray.includes(ChatMessageRatingType.THUMBS_UP)) {\n            feedbackTypeFilters = [ChatMessageRatingType.THUMBS_UP]\n        } else if (feedbackTypeFilterArray.includes(ChatMessageRatingType.THUMBS_DOWN)) {\n            feedbackTypeFilters = [ChatMessageRatingType.THUMBS_DOWN]\n        } else {\n            feedbackTypeFilters = undefined\n        }\n        return feedbackTypeFilters\n    } catch (e) {\n        return _feedbackTypeFilters\n    }\n}\n\nconst createChatMessage = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (!req.body) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                'Error: chatMessagesController.createChatMessage - request body not provided!'\n            )\n        }\n        const apiResponse = await chatMessagesService.createChatMessage(req.body)\n        return res.json(parseAPIResponse(apiResponse))\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getAllChatMessages = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        const _chatTypes = req.query?.chatType as string | undefined\n        let chatTypes: ChatType[] | undefined\n        if (_chatTypes) {\n            try {\n                if (Array.isArray(_chatTypes)) {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/chat-messages/index.ts#L21-L57","documentation":"Declared in chatMessagesController.createChatMessage (HTTP 412 when req.body is falsy), but the route that would expose it is COMMENTED OUT: routes/chat-messages/index.ts:8 reads '// router.post(['/', '/:id'], chatMessageController.createChatMessage)' with the note 'NOTE: Unused route'. A repo-wide search finds createChatMessage registered nowhere else (internal-chat-messages only wires getAllInternalChatMessages). So through the active REST API this guard is effectively DEAD CODE and cannot be triggered; it would only fire if the route is re-enabled or the controller method is invoked directly (e.g., in a test). If re-enabled it would mount at POST /api/v1/chatmessage (note the singular 'chatmessage' prefix).","triggerScenarios":"Not reachable via the shipped REST router. To trigger it you must either uncomment the POST route in routes/chat-messages/index.ts:8, re-register POST /api/v1/chatmessage against this controller elsewhere, or call chatMessagesController.createChatMessage directly in a test with a request whose body was not parsed.","commonSituations":"A developer investigating this string in logs will not see it from normal HTTP traffic. It appears in unit tests that exercise the controller directly without constructing req.body, or after someone re-enables the unused POST route without sending a JSON body.","solutions":["Treat absence of this error in production as expected; if you need createChatMessage, uncomment routes/chat-messages/index.ts:8 and ensure callers POST JSON with Content-Type: application/json.","If you are writing a controller-level unit test, construct req as { body: {...} } rather than {}.","If you do NOT need the route, leave it commented and remove the dead handler to reduce confusion."],"exampleFix":"// test/direct invocation fix: pass a parsed body\n// before\nconst req = { } as any\nawait chatMessagesController.createChatMessage(req, res, next) // -> 412\n\n// after\nconst req = { body: { chatflowid: 'cf-1', ... } } as any\nawait chatMessagesController.createChatMessage(req, res, next)","handlingStrategy":"validation","validationCode":"// Only relevant if you re-enable the (currently commented) POST route or call the controller directly.\nfunction createChatMessage(body: unknown) {\n  if (!body || typeof body !== 'object') {\n    throw new Error('createChatMessage requires a JSON body')\n  }\n  return fetch(`${BASE}/api/v1/chatmessage`, {\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":["Remember this route is currently disabled (commented in routes/chat-messages/index.ts:8); you will not hit this error over HTTP unless you re-enable it.","If you re-enable it, require Content-Type: application/json and a non-empty JSON body.","In unit tests invoking the controller directly, always construct req.body."],"tags":["dead-code","validation","express","request-body","precondition-failed","flowise","chat-messages"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}