{"record":{"id":"0edc60c479e92ccb","repo":"FlowiseAI/Flowise","slug":"error-chatmessagescontroller-removeallchatmessage","errorCode":null,"errorMessage":"Error: chatMessagesController.removeAllChatMessages - id not provided!","messagePattern":"Error: chatMessagesController\\.removeAllChatMessages - id not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"warning","filePath":"packages/server/src/controllers/chat-messages/index.ts","lineNumber":149,"sourceCode":"            sessionId,\n            startDate,\n            endDate,\n            messageId,\n            feedback,\n            feedbackTypeFilters,\n            activeWorkspaceId\n        )\n        return res.json(parseAPIResponse(apiResponse))\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst removeAllChatMessages = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        const appServer = getRunningExpressApp()\n        if (typeof req.params === 'undefined' || !req.params.id) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                'Error: chatMessagesController.removeAllChatMessages - id not provided!'\n            )\n        }\n        const orgId = req.user?.activeOrganizationId\n        if (!orgId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: chatMessagesController.removeAllChatMessages - 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: chatMessagesController.removeAllChatMessages - workspace ${workspaceId} not found!`\n            )\n        }","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/chat-messages/index.ts#L131-L167","documentation":"Thrown by removeAllChatMessages with HTTP 412 when req.params is undefined or req.params.id is falsy. Mounted via routes/chat-messages/index.ts:25 as DELETE ['/', '/:id'] under the singular /chatmessage prefix, i.e. DELETE /api/v1/chatmessage/:id. This is the first of three sequential guards (id, then organization, then workspace). As with the GET path, /chat-messages (plural) yields an Express 404 rather than this error.","triggerScenarios":"DELETE /api/v1/chatmessage/ (root form, no id). A 'clear messages' action invoked before a chatflow id is set. A cleanup script DELETE-ing the collection root.","commonSituations":"UI 'clear chat history' button with no chatflow selected; wrong path prefix ('chat-messages' vs 'chatmessage'); test iterating an empty id list.","solutions":["Call DELETE /api/v1/chatmessage/<id> with the chatflow id (singular prefix).","Guard the id is a non-empty string before issuing the DELETE."],"exampleFix":"// before\nawait fetch(`${BASE}/api/v1/chatmessage/`, { method: 'DELETE', headers })\n\n// after\nif (!chatflowId) throw new Error('chatflow id required')\nawait fetch(`${BASE}/api/v1/chatmessage/${encodeURIComponent(chatflowId)}`, { method: 'DELETE', headers })","handlingStrategy":"validation","validationCode":"function assertId(id: unknown): string {\n  if (typeof id !== 'string' || id.trim() === '') {\n    throw new Error('chatflow id is required')\n  }\n  return id\n}\nconst id = assertId(selectedChatflowId)\nawait fetch(`${BASE}/api/v1/chatmessage/${encodeURIComponent(id)}`, { method: 'DELETE', headers })","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0","tryCatchPattern":null,"preventionTips":["Use the singular prefix /api/v1/chatmessage and always include the id on DELETE.","Disable 'clear history' until a chatflow is selected.","Route these deletes through a helper that rejects empty ids."],"tags":["validation","express","path-param","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"}