Mintplex-Labs/anything-llm · error
Invalid message format. Expected an array of messages.
Error message
Invalid message format. Expected an array of messages.
What it means
Input guard on POST /workspace/:slug/suggested-messages: the messages body field is not an array, so the payload format is wrong for bulk-saving suggested messages and a 400 describing the expected array is returned.
Source
Thrown at server/endpoints/workspaces.js:587
response.status(200).json({ success: true, suggestedMessages });
} catch (error) {
console.error("Error fetching suggested messages:", error);
response
.status(500)
.json({ success: false, message: "Internal server error" });
}
}
);
app.post(
"/workspace/:slug/suggested-messages",
[validatedRequest, flexUserRoleValid([ROLES.admin, ROLES.manager])],
async (request, response) => {
try {
const { messages = [] } = reqBody(request);
const { slug } = request.params;
if (!Array.isArray(messages)) {
return response.status(400).json({
success: false,
message: "Invalid message format. Expected an array of messages.",
});
}
await WorkspaceSuggestedMessages.saveAll(messages, slug);
return response.status(200).json({
success: true,
message: "Suggested messages saved successfully.",
});
} catch (error) {
console.error("Error processing the suggested messages:", error);
response.status(500).json({
success: true,
message: "Error saving the suggested messages.",
});
}
}View on GitHub (pinned to 3aec848f28)
Solutions
- Send suggested messages as a JSON array.
- Each entry should be a message object matching the expected schema.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/endpoints/workspaces.js:587 when the library encounters an invalid state.
Common situations: Saving workspace suggested messages with a payload that is not an array.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/e66345a4a283ea3c.
Report an issue: GitHub.