{"record":{"id":"7f5bacddb903527a","repo":"FlowiseAI/Flowise","slug":"error-assistantscontroller-updateassistant-body","errorCode":null,"errorMessage":"Error: assistantsController.updateAssistant - body not provided!","messagePattern":"Error: assistantsController\\.updateAssistant - body not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"warning","filePath":"packages/server/src/controllers/assistants/index.ts","lineNumber":116,"sourceCode":"            )\n        }\n        const apiResponse = await assistantsService.getAssistantById(req.params.id, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst updateAssistant = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (typeof req.params === 'undefined' || !req.params.id) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: assistantsController.updateAssistant - id not provided!`\n            )\n        }\n        if (!req.body) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: assistantsController.updateAssistant - body not provided!`\n            )\n        }\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: assistantsController.updateAssistant - workspace ${workspaceId} not found!`\n            )\n        }\n        const apiResponse = await assistantsService.updateAssistant(req.params.id, req.body, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/assistants/index.ts#L98-L134","documentation":"Thrown by updateAssistant with HTTP 412 after the id guard passes, when req.body is falsy. As with createAssistant, this means the JSON body parser did not populate req.body — usually a missing Content-Type: application/json or an empty body.","triggerScenarios":"PUT /api/v1/assistants/<id> with no body or a non-JSON content type, so req.body is undefined.","commonSituations":"Client sent the update as form-encoded or with no Content-Type; proxy stripped Content-Type; body serialization bug producing an empty body.","solutions":["Send Content-Type: application/json with a JSON body on the PUT.","Ensure the body is a non-empty object (it is passed straight to the service).","Confirm express.json() runs before this router."],"exampleFix":"// before\nawait fetch(`${BASE}/api/v1/assistants/${id}`, { method: 'PUT', headers: authHeaders })\n\n// after\nawait fetch(`${BASE}/api/v1/assistants/${id}`, {\n  method: 'PUT',\n  headers: { ...authHeaders, 'Content-Type': 'application/json' },\n  body: JSON.stringify(changes)\n})","handlingStrategy":"validation","validationCode":"function updateAssistant(id: string, body: unknown) {\n  if (!body || typeof body !== 'object') {\n    throw new Error('updateAssistant requires a JSON body')\n  }\n  return fetch(`${BASE}/api/v1/assistants/${encodeURIComponent(id)}`, {\n    method: 'PUT',\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 on PUT.","Centralize PUT calls behind a helper that forces JSON content type and a non-empty body.","Confirm express.json() runs 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-12T23:17:12.415Z"}