FlowiseAI/Flowise · warning · InternalFlowiseError

Error: assistantsController.updateAssistant - body not provi

Error message

Error: assistantsController.updateAssistant - body not provided!

What it means

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.

Source

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

            )
        }
        const apiResponse = await assistantsService.getAssistantById(req.params.id, workspaceId)
        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

const updateAssistant = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (typeof req.params === 'undefined' || !req.params.id) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,
                `Error: assistantsController.updateAssistant - id not provided!`
            )
        }
        if (!req.body) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,
                `Error: assistantsController.updateAssistant - body not provided!`
            )
        }
        const workspaceId = req.user?.activeWorkspaceId
        if (!workspaceId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: assistantsController.updateAssistant - workspace ${workspaceId} not found!`
            )
        }
        const apiResponse = await assistantsService.updateAssistant(req.params.id, req.body, workspaceId)
        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Send Content-Type: application/json with a JSON body on the PUT.
  2. Ensure the body is a non-empty object (it is passed straight to the service).
  3. Confirm express.json() runs before this router.

Example fix

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

// after
await fetch(`${BASE}/api/v1/assistants/${id}`, {
  method: 'PUT',
  headers: { ...authHeaders, 'Content-Type': 'application/json' },
  body: JSON.stringify(changes)
})
Defensive patterns

Strategy: validation

Validate before calling

function updateAssistant(id: string, body: unknown) {
  if (!body || typeof body !== 'object') {
    throw new Error('updateAssistant requires a JSON body')
  }
  return fetch(`${BASE}/api/v1/assistants/${encodeURIComponent(id)}`, {
    method: 'PUT',
    headers: { ...authHeaders, 'Content-Type': 'application/json' },
    body: JSON.stringify(body)
  })
}

Type guard

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

Prevention

When it happens

Trigger: PUT /api/v1/assistants/<id> with no body or a non-JSON content type, so req.body is undefined.

Common situations: Client sent the update as form-encoded or with no Content-Type; proxy stripped Content-Type; body serialization bug producing an empty body.

Related errors


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