{"record":{"id":"690ba8449d73992c","repo":"Mintplex-Labs/anything-llm","slug":"message-is-empty-690ba8","errorCode":null,"errorMessage":"Message is empty","messagePattern":"Message is empty","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"server/endpoints/api/workspaceThread/index.js","lineNumber":435,"sourceCode":"        });\n        if (!thread) {\n          response.status(404).json({\n            id: uuidv4(),\n            type: \"abort\",\n            textResponse: null,\n            sources: [],\n            close: true,\n            error: `Thread ${threadSlug} not found.`,\n          });\n          return;\n        }\n\n        const resolvedMode = mode ?? workspace.chatMode;\n        if (\n          (!message?.length || !VALID_CHAT_MODE.includes(resolvedMode)) &&\n          !reset\n        ) {\n          response.status(400).json({\n            id: uuidv4(),\n            type: \"abort\",\n            textResponse: null,\n            sources: [],\n            close: true,\n            error: !message?.length\n              ? \"Message is empty\"\n              : `${resolvedMode} is not a valid mode.`,\n          });\n          return;\n        }\n\n        const user = userId ? await User.get({ id: Number(userId) }) : null;\n        const result = await ApiChatHandler.chatSync({\n          workspace,\n          message,\n          mode: resolvedMode,\n          user,","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/api/workspaceThread/index.js#L417-L453","documentation":"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.","triggerScenarios":"Sending {message:''} or omitting message; sending {message:null}; JSON body not parsed due to missing application/json Content-Type so message never arrives.","commonSituations":"Empty textarea submits; templated prompts rendering to empty string; client libraries defaulting unspecified string fields to empty rather than dropping them.","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"],"exampleFix":"// before\nif (!prompt) prompt = ' ';\n// after\nif (!prompt?.trim()) throw new Error('message required (or use reset:true)');","handlingStrategy":"validation","validationCode":"if (!message?.length && !reset) throw new Error('message required unless reset:true');","typeGuard":"const hasMessage = (b) => typeof b?.message === 'string' && b.message.length > 0;","tryCatchPattern":null,"preventionTips":["Guard empty input before the request","Use reset:true for history clears","Send correct Content-Type","Field is 'message', not 'prompt' or 'text'"],"tags":["anythingllm","developer-api","workspace-thread","chat","request-body","http-400","validation"],"backgroundTag":"request-body-validation","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}