RocketChat/Rocket.Chat · error · Error
message-length-exceeds-character-limit
Error message
message-length-exceeds-character-limit
What it means
Thrown by POST /livechat/message (message.ts:45-50) when the setting `Livechat_enable_message_character_limit` is true and msg.length exceeds parseInt(`Livechat_message_character_limit`). This is a configurable server-side cap on visitor message length. Returns HTTP 400 { success:false, error:'message-length-exceeds-character-limit' }.
Source
Thrown at apps/meteor/server/api/v1/omnichannel/message.ts:49
const guest = await findGuest(token);
if (!guest) {
throw new Error('invalid-token');
}
const room = await findRoom(token, rid);
if (!room) {
throw new Error('invalid-room');
}
if (!room.open) {
throw new Error('room-closed');
}
if (
settings.get('Livechat_enable_message_character_limit') &&
msg.length > parseInt(settings.get('Livechat_message_character_limit'))
) {
throw new Error('message-length-exceeds-character-limit');
}
const _id = this.bodyParams._id || Random.id();
const messageToSend = {
guest,
message: {
_id,
rid,
msg,
token,
},
agent,
roomInfo: {
source: {
type: isWidget(this.request.headers) ? OmnichannelSourceType.WIDGET : OmnichannelSourceType.API,
},
},View on GitHub (pinned to f9d3ec372b)
Solutions
- Truncate or split the message client-side so it fits `Livechat_message_character_limit`.
- Read the limit from the widget config (limitTextPath / limitTextLength) and enforce it before sending.
- As admin, raise `Livechat_message_character_limit` or disable `Livechat_enable_message_character_limit`.
Example fix
// before
POST /livechat/message { token, rid, msg: longText }
// after
const limit = settings.get('Livechat_message_character_limit');
const safe = msg.length > limit ? msg.slice(0, limit) : msg;
POST /livechat/message { token, rid, msg: safe } Defensive patterns
Strategy: validation
Validate before calling
const enabled = settings.get('Livechat_enable_message_character_limit');
const limit = parseInt(`${settings.get('Livechat_message_character_limit')}`, 10);
if (enabled && msg.length > limit) {
msg = msg.slice(0, limit); // or split into multiple messages
}
// safe to POST /livechat/message Type guard
const fitsLimit = (msg: string, enabled: boolean, limit: number) => !enabled || msg.length <= limit;
Try / catch
try { await sendMessage({ token, rid, msg }); }
catch (e) { if (e instanceof Error && e.message === 'message-length-exceeds-character-limit') { /* truncate and retry */ } else throw e; } Prevention
- Read the limit from the widget config and cap input client-side.
- Show a character counter when the limit is enabled.
- Keep clients in sync with admin limit changes.
When it happens
Trigger: Posting a `msg` whose character count is greater than the configured `Livechat_message_character_limit` while the limit setting is enabled.
Common situations: User pastes long text; client does not enforce the limit; admin lowered the limit; the widget's limitTextLength config was not respected.
Related errors
- error-invalid-sla
- Invalid service URL
- error-forwarding-department-target-not-allowed
- error-invalid-sla
- error-invalid-priority
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/f0d75a9c14f9bb95.
Report an issue: GitHub.