{"record":{"id":"b9a540fd5b806f22","repo":"FlowiseAI/Flowise","slug":"error-credentialscontroller-createcredential-bo","errorCode":null,"errorMessage":"Error: credentialsController.createCredential - body not provided!","messagePattern":"Error: credentialsController\\.createCredential - body not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"error","filePath":"packages/server/src/controllers/credentials/index.ts","lineNumber":9,"sourceCode":"import { Request, Response, NextFunction } from 'express'\nimport credentialsService from '../../services/credentials'\nimport { InternalFlowiseError } from '../../errors/internalFlowiseError'\nimport { StatusCodes } from 'http-status-codes'\n\nconst createCredential = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (!req.body) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: credentialsController.createCredential - body not provided!`\n            )\n        }\n        const body = req.body\n        body.workspaceId = req.user?.activeWorkspaceId\n        const apiResponse = await credentialsService.createCredential(body)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst deleteCredentials = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (typeof req.params === 'undefined' || !req.params.id) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/credentials/index.ts#L1-L27","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Send a JSON object body with Content-Type: application/json.","Ensure express.json() (or the equivalent body parser) is registered globally before this route.","Raise the body-size limit if large credential payloads are rejected before reaching the handler."],"exampleFix":"// before\nfetch('/api/v1/credentials', { method: 'POST' })\n// after\nfetch('/api/v1/credentials', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ credentialName, inputs: {...} })\n})","handlingStrategy":"validation","validationCode":"function createCredential(payload: Record<string, unknown>) {\n  if (!payload || typeof payload !== 'object') throw new Error('credential body required')\n  return fetch('/api/v1/credentials', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) })\n}","typeGuard":"const isPlainObject = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v)","tryCatchPattern":"try { await createCredential(payload) } catch (e) { if (e.statusCode === 412) throw new Error('send a JSON body with Content-Type application/json') }","preventionTips":["Always send Content-Type: application/json for POST.","Ensure express.json() is mounted and sized for the payload.","Send at least an empty object {} if the endpoint allows it."],"tags":["flowise","controller","validation","precondition-failed","body-shape","credentials","typescript"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}