FlowiseAI/Flowise · error · InternalFlowiseError

Error: credentialsController.createCredential - body not pro

Error message

Error: credentialsController.createCredential - body not provided!

What it means

Thrown by credentialsController.createCredential when req.body is falsy. This is the create endpoint for stored credentials; it also stamps body.workspaceId from the authenticated user's active workspace before delegating to the service. Returned as PRECONDITION_FAILED (412). A missing body usually means JSON parsing did not run, not that the client sent an empty object ({} is truthy).

Source

Thrown at packages/server/src/controllers/credentials/index.ts:9

import { Request, Response, NextFunction } from 'express'
import credentialsService from '../../services/credentials'
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
import { StatusCodes } from 'http-status-codes'

const createCredential = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (!req.body) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,
                `Error: credentialsController.createCredential - body not provided!`
            )
        }
        const body = req.body
        body.workspaceId = req.user?.activeWorkspaceId
        const apiResponse = await credentialsService.createCredential(body)
        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

const deleteCredentials = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (typeof req.params === 'undefined' || !req.params.id) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Send a JSON object body with Content-Type: application/json.
  2. Ensure express.json() (or the equivalent body parser) is registered globally before this route.
  3. Raise the body-size limit if large credential payloads are rejected before reaching the handler.

Example fix

// before
fetch('/api/v1/credentials', { method: 'POST' })
// after
fetch('/api/v1/credentials', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ credentialName, inputs: {...} })
})
Defensive patterns

Strategy: validation

Validate before calling

function createCredential(payload: Record<string, unknown>) {
  if (!payload || typeof payload !== 'object') throw new Error('credential body required')
  return fetch('/api/v1/credentials', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) })
}

Type guard

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

Try / catch

try { await createCredential(payload) } catch (e) { if (e.statusCode === 412) throw new Error('send a JSON body with Content-Type application/json') }

Prevention

When it happens

Trigger: The request has no body, a non-JSON Content-Type so express.json() skips parsing, body-parsing middleware not mounted, or a body that failed to parse and was left undefined.

Common situations: Client forgot Content-Type: application/json, sent an empty body, or the express.json() middleware is misconfigured/limited below the payload size. Note {} passes this guard but may fail downstream validation.

Related errors


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