{"record":{"id":"0b5f1d353386f450","repo":"Mintplex-Labs/anything-llm","slug":"name-and-config-are-required","errorCode":null,"errorMessage":"Name and config are required","messagePattern":"Name and config are required","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"server/endpoints/agentFlows.js","lineNumber":21,"sourceCode":"  flexUserRoleValid,\n  ROLES,\n} = require(\"../utils/middleware/multiUserProtected\");\nconst { validatedRequest } = require(\"../utils/middleware/validatedRequest\");\nconst { Telemetry } = require(\"../models/telemetry\");\n\nfunction agentFlowEndpoints(app) {\n  if (!app) return;\n\n  // Save a flow configuration\n  app.post(\n    \"/agent-flows/save\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const { name, config, uuid } = request.body;\n\n        if (!name || !config) {\n          return response.status(400).json({\n            success: false,\n            error: \"Name and config are required\",\n          });\n        }\n\n        const flow = AgentFlows.saveFlow(name, config, uuid);\n        if (!flow || !flow.success)\n          return response\n            .status(200)\n            .json({ flow: null, error: flow.error || \"Failed to save flow\" });\n\n        if (!uuid) {\n          await Telemetry.sendTelemetry(\"agent_flow_created\", {\n            blockCount: config.blocks?.length || 0,\n          });\n        }\n\n        return response.status(200).json({","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/agentFlows.js#L3-L39","documentation":"AnythingLLM's agent-flow save endpoint (POST /agent-flows/save, admin-only) returns this 400 when the request body lacks a truthy `name` or `config`. The check is `!name || !config`, so an empty string, null, undefined, or missing key for either field trips it; `uuid` is optional. It is a plain input-validation guard before AgentFlows.saveFlow writes the flow JSON to storage/plugins/agent-flows.","triggerScenarios":"POST /agent-flows/save with body {}, with name:\"\" , with config omitted, with config:null, or a request sent without Content-Type: application/json so the body never parses. Also happens when a client sends the payload as form-data instead of JSON.","commonSituations":"Front-end form submitted with an empty flow name; importing/saving a flow whose config object was serialized to undefined; fetch with mismatched headers; automated scripts that assume only `config` is required.","solutions":["Send a JSON body containing both a non-empty `name` string and a `config` object, e.g. {\"name\":\"My flow\",\"config\":{\"steps\":[...]}}","Set the Content-Type: application/json header and verify request.body is actually parsed (check express.json middleware is mounted)","If saving an existing flow, include the `uuid` returned by /agent-flows/list to update it instead of creating a new one"],"exampleFix":"// before\nawait fetch('/api/agent-flows/save', {\n  method: 'POST',\n  body: JSON.stringify({ name: '' , config }) // name is empty -> 400\n});\n\n// after\nawait fetch('/api/agent-flows/save', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ name: name.trim() || 'Untitled flow', config: config ?? { steps: [] }, uuid })\n});","handlingStrategy":"validation","validationCode":"function buildFlowPayload(name, config, uuid) {\n  if (!name || typeof name !== 'string') throw new Error('name must be a non-empty string');\n  if (!config || typeof config !== 'object' || Array.isArray(config.steps) === false) {\n    throw new Error('config must be an object with a steps array');\n  }\n  return uuid ? { name, config, uuid } : { name, config };\n}","typeGuard":"function isFlowSavePayload(b) {\n  return Boolean(b) && typeof b.name === 'string' && b.name.length > 0 &&\n    typeof b.config === 'object' && b.config !== null && Array.isArray(b.config.steps);\n}","tryCatchPattern":null,"preventionTips":["Always set Content-Type: application/json on agent-flow POSTs","Default empty names client-side (e.g. 'Untitled flow') instead of sending ''","Keep the config schema (steps array) invariant in your flow editor model"],"tags":["agent-flows","http-400","request-body","validation"],"backgroundTag":"request-body-validation","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}