mirror of
https://github.com/Mintplex-Labs/anything-llm
synced 2026-04-25 17:15:37 +02:00
fix: validate chat message input (#4811)
* fix: validate chat message input * fix: align message validation for thread stream-chat endpoint --------- Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
This commit is contained in:
@@ -30,14 +30,14 @@ function chatEndpoints(app) {
|
||||
const { message, attachments = [] } = reqBody(request);
|
||||
const workspace = response.locals.workspace;
|
||||
|
||||
if (!message?.length) {
|
||||
if (typeof message !== "string" || message.trim().length === 0) {
|
||||
response.status(400).json({
|
||||
id: uuidv4(),
|
||||
type: "abort",
|
||||
textResponse: null,
|
||||
sources: [],
|
||||
close: true,
|
||||
error: !message?.length ? "Message is empty." : null,
|
||||
error: "Message is empty.",
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -117,14 +117,14 @@ function chatEndpoints(app) {
|
||||
const workspace = response.locals.workspace;
|
||||
const thread = response.locals.thread;
|
||||
|
||||
if (!message?.length) {
|
||||
if (typeof message !== "string" || message.trim().length === 0) {
|
||||
response.status(400).json({
|
||||
id: uuidv4(),
|
||||
type: "abort",
|
||||
textResponse: null,
|
||||
sources: [],
|
||||
close: true,
|
||||
error: !message?.length ? "Message is empty." : null,
|
||||
error: "Message is empty.",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user