{"record":{"id":"cd2689b0602a5aac","repo":"FlowiseAI/Flowise","slug":"error-credentialscontroller-updatecredential-bo","errorCode":null,"errorMessage":"Error: credentialsController.updateCredential - body not provided!","messagePattern":"Error: credentialsController\\.updateCredential - body not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"warning","filePath":"packages/server/src/controllers/credentials/index.ts","lineNumber":114,"sourceCode":"            )\n        }\n        const apiResponse = await credentialsService.revealCredentialById(req.params.id, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst updateCredential = 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,\n                `Error: credentialsController.updateCredential - id not provided!`\n            )\n        }\n        if (!req.body) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: credentialsController.updateCredential - body not provided!`\n            )\n        }\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: credentialsController.updateCredential - workspace ${workspaceId} not found!`\n            )\n        }\n        const apiResponse = await credentialsService.updateCredential(req.params.id, req.body, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/credentials/index.ts#L96-L132","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait fetch(`/api/v1/credentials/${id}`, { method: 'PUT' })\n\n// after\nawait fetch(`/api/v1/credentials/${id}`, {\n  method: 'PUT',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ name: 'new-name', ... })\n})","handlingStrategy":"validation","validationCode":"function requireUpdateBody(body: unknown): Record<string, unknown> {\n  if (!body || typeof body !== 'object' || Array.isArray(body)) {\n    throw new Error('update body must be a non-empty JSON object')\n  }\n  if (Object.keys(body).length === 0) {\n    throw new Error('update body is empty')\n  }\n  return body\n}\n\nconst body = requireUpdateBody(payload)\nawait api.updateCredential(id, body)","typeGuard":"function isPlainObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v)\n}","tryCatchPattern":"try {\n  await api.updateCredential(id, payload)\n} catch (e) {\n  if (e.status === 412 && /body not provided/.test(e.message)) {\n    // likely a missing Content-Type or empty body — fix the request\n    console.error('request reached the server without a body')\n  }\n  throw e\n}","preventionTips":["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."],"tags":["validation","request-body","client-bug","credentials","flowise"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}