FlowiseAI/Flowise · warning · InternalFlowiseError

Error: assistantsController.generateAssistantInstruction - b

Error message

Error: assistantsController.generateAssistantInstruction - body not provided!

What it means

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.

Source

Thrown at packages/server/src/controllers/assistants/index.ts:172

        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

const getTools = async (req: Request, res: Response, next: NextFunction) => {
    try {
        const apiResponse = await assistantsService.getTools()
        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

const generateAssistantInstruction = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (!req.body) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,
                `Error: assistantsController.generateAssistantInstruction - body not provided!`
            )
        }
        const apiResponse = await assistantsService.generateAssistantInstruction(req.body.task, req.body.selectedChatModel)
        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

export default {
    createAssistant,
    deleteAssistant,
    getAllAssistants,
    getAssistantById,
    updateAssistant,
    getChatModels,

View on GitHub (pinned to abe4a8601a)

Solutions

  1. POST a JSON object with Content-Type: application/json, including at least { task, selectedChatModel }.
  2. Guard the payload is a non-empty object before sending.
  3. Confirm express.json() runs before this router.

Example fix

// before
await fetch(`${BASE}/api/v1/assistants/generate/instruction`, { method: 'POST', headers: authHeaders })

// after
await fetch(`${BASE}/api/v1/assistants/generate/instruction`, {
  method: 'POST',
  headers: { ...authHeaders, 'Content-Type': 'application/json' },
  body: JSON.stringify({ task: 'Summarize PDFs', selectedChatModel: 'gpt-4o' })
})
Defensive patterns

Strategy: validation

Validate before calling

function generateInstruction(task: unknown, selectedChatModel: unknown) {
  if (typeof task !== 'string' || !task) throw new Error('task is required')
  if (typeof selectedChatModel !== 'string' || !selectedChatModel) throw new Error('selectedChatModel is required')
  return fetch(`${BASE}/api/v1/assistants/generate/instruction`, {
    method: 'POST',
    headers: { ...authHeaders, 'Content-Type': 'application/json' },
    body: JSON.stringify({ task, selectedChatModel })
  })
}

Type guard

const isJsonObject = (b: unknown): b is Record<string, unknown> =>
  !!b && typeof b === 'object' && !Array.isArray(b)

Prevention

When it happens

Trigger: POST /api/v1/assistants/generate/instruction with no body or a non-JSON content type, leaving req.body undefined.

Common situations: Client invoked the 'generate instruction' action without assembling the payload; missing Content-Type: application/json; proxy stripping Content-Type.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/5d99655189d5b734. Report an issue: GitHub.