{"record":{"id":"5d99655189d5b734","repo":"FlowiseAI/Flowise","slug":"error-assistantscontroller-generateassistantinstr","errorCode":null,"errorMessage":"Error: assistantsController.generateAssistantInstruction - body not provided!","messagePattern":"Error: assistantsController\\.generateAssistantInstruction - body not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"warning","filePath":"packages/server/src/controllers/assistants/index.ts","lineNumber":172,"sourceCode":"        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getTools = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        const apiResponse = await assistantsService.getTools()\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst generateAssistantInstruction = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (!req.body) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: assistantsController.generateAssistantInstruction - body not provided!`\n            )\n        }\n        const apiResponse = await assistantsService.generateAssistantInstruction(req.body.task, req.body.selectedChatModel)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nexport default {\n    createAssistant,\n    deleteAssistant,\n    getAllAssistants,\n    getAssistantById,\n    updateAssistant,\n    getChatModels,","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/assistants/index.ts#L154-L190","documentation":"Thrown by generateAssistantInstruction with HTTP 412 when req.body is falsy. Mounted at POST /api/v1/assistants/generate/instruction (routes/assistants/index.ts:25). The handler subsequently reads req.body.task and req.body.selectedChatModel and passes them to the service, so the body must be a JSON object.","triggerScenarios":"POST /api/v1/assistants/generate/instruction with no body or a non-JSON content type, leaving req.body undefined.","commonSituations":"Client invoked the 'generate instruction' action without assembling the payload; missing Content-Type: application/json; proxy stripping Content-Type.","solutions":["POST a JSON object with Content-Type: application/json, including at least { task, selectedChatModel }.","Guard the payload is a non-empty object before sending.","Confirm express.json() runs before this router."],"exampleFix":"// before\nawait fetch(`${BASE}/api/v1/assistants/generate/instruction`, { method: 'POST', headers: authHeaders })\n\n// after\nawait fetch(`${BASE}/api/v1/assistants/generate/instruction`, {\n  method: 'POST',\n  headers: { ...authHeaders, 'Content-Type': 'application/json' },\n  body: JSON.stringify({ task: 'Summarize PDFs', selectedChatModel: 'gpt-4o' })\n})","handlingStrategy":"validation","validationCode":"function generateInstruction(task: unknown, selectedChatModel: unknown) {\n  if (typeof task !== 'string' || !task) throw new Error('task is required')\n  if (typeof selectedChatModel !== 'string' || !selectedChatModel) throw new Error('selectedChatModel is required')\n  return fetch(`${BASE}/api/v1/assistants/generate/instruction`, {\n    method: 'POST',\n    headers: { ...authHeaders, 'Content-Type': 'application/json' },\n    body: JSON.stringify({ task, selectedChatModel })\n  })\n}","typeGuard":"const isJsonObject = (b: unknown): b is Record<string, unknown> =>\n  !!b && typeof b === 'object' && !Array.isArray(b)","tryCatchPattern":null,"preventionTips":["Always POST with Content-Type: application/json to the generate endpoint.","Validate task and selectedChatModel are present before sending.","Route generative POSTs through a helper that forces JSON content type."],"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"}