Mintplex-Labs/anything-llm · warning
Message is empty
Error message
Message is empty
What it means
HTTP 400 from POST /api/v1/workspace/:slug/thread/:threadSlug/chat when message is falsy/empty (!message?.length) and reset is not true. Identical guard to the workspace stream-chat endpoint: a reset request (to clear thread history) is the only sanctioned way to send an empty message. Aborts come back in the abort-shaped body.
Source
Thrown at server/endpoints/api/workspaceThread/index.js:435
});
if (!thread) {
response.status(404).json({
id: uuidv4(),
type: "abort",
textResponse: null,
sources: [],
close: true,
error: `Thread ${threadSlug} not found.`,
});
return;
}
const resolvedMode = mode ?? workspace.chatMode;
if (
(!message?.length || !VALID_CHAT_MODE.includes(resolvedMode)) &&
!reset
) {
response.status(400).json({
id: uuidv4(),
type: "abort",
textResponse: null,
sources: [],
close: true,
error: !message?.length
? "Message is empty"
: `${resolvedMode} is not a valid mode.`,
});
return;
}
const user = userId ? await User.get({ id: Number(userId) }) : null;
const result = await ApiChatHandler.chatSync({
workspace,
message,
mode: resolvedMode,
user,View on GitHub (pinned to 3aec848f28)
Solutions
- Always send a non-empty message string
- To clear thread history only, send {reset:true} with or without a message
- Set Content-Type: application/json and verify the serialized body
- Disable send while input is blank
Example fix
// before
if (!prompt) prompt = ' ';
// after
if (!prompt?.trim()) throw new Error('message required (or use reset:true)'); Defensive patterns
Strategy: validation
Validate before calling
if (!message?.length && !reset) throw new Error('message required unless reset:true'); Type guard
const hasMessage = (b) => typeof b?.message === 'string' && b.message.length > 0;
Prevention
- Guard empty input before the request
- Use reset:true for history clears
- Send correct Content-Type
- Field is 'message', not 'prompt' or 'text'
When it happens
Trigger: Sending {message:''} or omitting message; sending {message:null}; JSON body not parsed due to missing application/json Content-Type so message never arrives.
Common situations: Empty textarea submits; templated prompts rendering to empty string; client libraries defaulting unspecified string fields to empty rather than dropping them.
Related errors
- Query parameter cannot be empty.
- ${resolvedMode} is not a valid mode.
- Workspace ${slug} not found.
- Thread ${threadSlug} not found.
- e.message
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/690ba8449d73992c.
Report an issue: GitHub.