Mintplex-Labs/anything-llm · warning

Name and config are required

Error message

Name and config are required

What it means

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.

Source

Thrown at server/endpoints/agentFlows.js:21

  flexUserRoleValid,
  ROLES,
} = require("../utils/middleware/multiUserProtected");
const { validatedRequest } = require("../utils/middleware/validatedRequest");
const { Telemetry } = require("../models/telemetry");

function agentFlowEndpoints(app) {
  if (!app) return;

  // Save a flow configuration
  app.post(
    "/agent-flows/save",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (request, response) => {
      try {
        const { name, config, uuid } = request.body;

        if (!name || !config) {
          return response.status(400).json({
            success: false,
            error: "Name and config are required",
          });
        }

        const flow = AgentFlows.saveFlow(name, config, uuid);
        if (!flow || !flow.success)
          return response
            .status(200)
            .json({ flow: null, error: flow.error || "Failed to save flow" });

        if (!uuid) {
          await Telemetry.sendTelemetry("agent_flow_created", {
            blockCount: config.blocks?.length || 0,
          });
        }

        return response.status(200).json({

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Send a JSON body containing both a non-empty `name` string and a `config` object, e.g. {"name":"My flow","config":{"steps":[...]}}
  2. Set the Content-Type: application/json header and verify request.body is actually parsed (check express.json middleware is mounted)
  3. If saving an existing flow, include the `uuid` returned by /agent-flows/list to update it instead of creating a new one

Example fix

// before
await fetch('/api/agent-flows/save', {
  method: 'POST',
  body: JSON.stringify({ name: '' , config }) // name is empty -> 400
});

// after
await fetch('/api/agent-flows/save', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ name: name.trim() || 'Untitled flow', config: config ?? { steps: [] }, uuid })
});
Defensive patterns

Strategy: validation

Validate before calling

function buildFlowPayload(name, config, uuid) {
  if (!name || typeof name !== 'string') throw new Error('name must be a non-empty string');
  if (!config || typeof config !== 'object' || Array.isArray(config.steps) === false) {
    throw new Error('config must be an object with a steps array');
  }
  return uuid ? { name, config, uuid } : { name, config };
}

Type guard

function isFlowSavePayload(b) {
  return Boolean(b) && typeof b.name === 'string' && b.name.length > 0 &&
    typeof b.config === 'object' && b.config !== null && Array.isArray(b.config.steps);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/0b5f1d353386f450. Report an issue: GitHub.