FlowiseAI/Flowise · warning · InternalFlowiseError

Error: credentialsController.updateCredential - body not pro

Error message

Error: credentialsController.updateCredential - body not provided!

What it means

Thrown by updateCredential when req.body is falsy. Because Express only populates req.body when a body parser runs and the request has a body, this fires for an empty PUT body, a missing Content-Type: application/json header, or a body-parser misconfiguration. Returns HTTP 412 PRECONDITION_FAILED.

Source

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

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

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

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Confirm the PUT request has a JSON body and Content-Type: application/json header.
  2. On the client, always pass an explicit object: api.updateCredential(id, payload || {}).
  3. Verify express.json() middleware is mounted before the credentials routes in the app chain.
  4. Check the body is not larger than the configured limit (default 100kb in Express).
  5. In tests, pass a real object as the body argument, not undefined.

Example fix

// before
await fetch(`/api/v1/credentials/${id}`, { method: 'PUT' })

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

Strategy: validation

Validate before calling

function requireUpdateBody(body: unknown): Record<string, unknown> {
  if (!body || typeof body !== 'object' || Array.isArray(body)) {
    throw new Error('update body must be a non-empty JSON object')
  }
  if (Object.keys(body).length === 0) {
    throw new Error('update body is empty')
  }
  return body
}

const body = requireUpdateBody(payload)
await api.updateCredential(id, body)

Type guard

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

Try / catch

try {
  await api.updateCredential(id, payload)
} catch (e) {
  if (e.status === 412 && /body not provided/.test(e.message)) {
    // likely a missing Content-Type or empty body — fix the request
    console.error('request reached the server without a body')
  }
  throw e
}

Prevention

When it happens

Trigger: PUT /api/v1/credentials/:id sent with no body (e.g. fetch with no body argument). Request with Content-Type missing or wrong (text/plain) so JSON middleware skips parsing. A client that calls updateCredential(id, undefined). Body parser limit exceeded so body is dropped.

Common situations: Frontend calling fetch with method:'PUT' but forgetting the body field. Wrong Content-Type header from a hand-rolled axios call. Express body-parser registered after this route. Payload larger than the configured json limit.

Related errors


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