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
- Confirm the PUT request has a JSON body and Content-Type: application/json header.
- On the client, always pass an explicit object: api.updateCredential(id, payload || {}).
- Verify express.json() middleware is mounted before the credentials routes in the app chain.
- Check the body is not larger than the configured limit (default 100kb in Express).
- 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
- Always send Content-Type: application/json and a stringified JSON body on PUT/PATCH/POST.
- Mount express.json() globally before route registration.
- Set an explicit json body limit so large payloads fail loudly, not silently drop req.body.
- In tests, pass a real object — never undefined — as the body.
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
- Error: credentialsController.getCredentialById - id not prov
- Error: credentialsController.revealCredentialById - id not p
- Error: credentialsController.updateCredential - id not provi
- Error: customMcpServersController.createCustomMcpServer - bo
- Error: assistantsController.createAssistant - body not provi
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/cd2689b0602a5aac.
Report an issue: GitHub.