Mintplex-Labs/anything-llm · warning

Message is empty.

Error message

Message is empty.

What it means

Message validation inside canRespond: the same 400 response covers two conditions, and when !message?.length the payload reports 'Message is empty.'. Anything falsy or zero-length — empty string, null, undefined — triggers it. The embed itself and session are fine; only the text is missing.

Source

Thrown at server/utils/middleware/embedMiddleware.js:112

      });
      return;
    }

    const { sessionId, message } = reqBody(request);
    if (typeof sessionId !== "string" || !validate(String(sessionId))) {
      response.status(404).json({
        id: uuidv4(),
        type: "abort",
        textResponse: null,
        sources: [],
        close: true,
        error: "Invalid session ID.",
      });
      return;
    }

    if (!message?.length || !VALID_CHAT_MODE.includes(embed.chat_mode)) {
      response.status(400).json({
        id: uuidv4(),
        type: "abort",
        textResponse: null,
        sources: [],
        close: true,
        error: !message?.length
          ? "Message is empty."
          : `${embed.chat_mode} is not a valid mode.`,
      });
      return;
    }

    if (
      !isNaN(embed.max_chats_per_day) &&
      Number(embed.max_chats_per_day) > 0
    ) {
      const dailyChatCount = await EmbedChats.count({
        embed_id: embed.id,

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Disable the send action when the trimmed input is empty
  2. Build the request body from the captured text before clearing the input state
  3. Send {"message": "...", "sessionId": "<uuid>"} as JSON with Content-Type: application/json

Example fix

// before
if (e.key === 'Enter') send({ sessionId }); // message omitted -> 400

// after
const text = input.value.trim();
if (!text) return; // guard
send({ sessionId, message: text });
Defensive patterns

Strategy: validation

Validate before calling

const text = input.value.trim();
if (text.length === 0) return; // never send an empty message
send({ sessionId, message: text });

Type guard

const isNonEmptyMessage = (m) => typeof m === 'string' && m.length > 0;

Try / catch

if (res.status === 400) {
  const data = await res.json();
  if (data.error === 'Message is empty.') reEnableSendButton(); // client bug, fix guard
}

Prevention

When it happens

Trigger: Widget sends {sessionId: '<uuid>'} without a message key; whitespace-only string is NOT caught by length check but a truly empty string is; double-submit where the input was cleared before the request body was built.

Common situations: Enter keypress handler firing on an empty textarea; message state cleared optimistically before serialization; test scripts sending only sessionId.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


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