Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(conversations): raise widget message cap to 10,000 and warn over it (#72885)

Christiaan Hendriksenb7e136a5541d
diff --git a/frontend/src/lib/components/Support/supportLogic.test.ts b/frontend/src/lib/components/Support/supportLogic.test.ts
index b2ee0af4f397..f5aebff84e80 100644
--- a/frontend/src/lib/components/Support/supportLogic.test.ts
+++ b/frontend/src/lib/components/Support/supportLogic.test.ts
@@ -8,7 +8,12 @@ import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePane
import { initKeaTests } from '~/test/init'
import { OrganizationBasicType, Region, SidePanelTab, TeamPublicType } from '~/types'
-import { getPublicSupportSnippet, SupportFormFields, supportLogic } from './supportLogic'
+import {
+ CONVERSATIONS_MESSAGE_MAX_LENGTH,
+ getPublicSupportSnippet,
+ SupportFormFields,
+ supportLogic,
+} from './supportLogic'
import * as SupportModal from './SupportModal'
// supportLogic and SupportModal import each other, so jest.mock('./SupportModal') leaves supportLogic
@@ -216,6 +221,22 @@ describe('supportLogic', () => {
expect(sendMessage.mock.calls[0][0]).toBe('Just a message')
})
+ it('blocks an over-limit message client-side without sending or falling back to Zendesk', async () => {
+ const sendMessage = jest.fn().mockResolvedValue({ ticket_id: 't1' })
+ ;(posthog as any).conversations = { isAvailable: () => true, sendMessage }
+ enableConversationsFlag()
+
+ await logic.asyncActions.submitSupportTicket({
+ ...FORM_FIELDS,
+ message: 'a'.repeat(CONVERSATIONS_MESSAGE_MAX_LENGTH + 1),
+ })
+
+ // Guarded before it leaves the browser: no widget send, and no Zendesk double-file
+ expect(sendMessage).not.toHaveBeenCalled()
+ expect(zendeskCalls()).toHaveLength(0)
+ expect(logic.values.lastSubmittedTicketId).toBeNull()
+ })
+
it('does not fall back to Zendesk when sendMessage throws, to avoid double-filing', async () => {
;(posthog as any).conversations = {
isAvailable: () => true,
diff --git a/frontend/src/lib/components/Support/supportLogic.ts b/frontend/src/lib/components/Support/supportLogic.ts
index 9c745315629d..b633a46824db 100644
--- a/frontend/src/lib/components/Support/supportLogic.ts
+++ b/frontend/src/lib/components/Support/supportLogic.ts
@@ -139,6 +139,23 @@ async function waitForConversations(timeoutMs = 5000): Promise<boolean> {
return !!posthog.conversations?.isAvailable()
}
+// Mirrors the widget message serializer cap (WidgetMessageSerializer.message). Support submits post
+// through posthog.conversations.sendMessage (the widget endpoint), so guard against the same cap.
+export const CONVERSATIONS_MESSAGE_MAX_LENGTH = 10000
+
+// Shared over-limit guard for the conversations composer surfaces (support form + side panel). Shows
+// an error toast and returns true when the message exceeds the widget cap, so callers bail before
+// hitting the endpoint and surfacing only a generic send-failure toast.
+export function warnIfMessageTooLong(message: string): boolean {
+ if (message.length > CONVERSATIONS_MESSAGE_MAX_LENGTH) {
+ lemonToast.error(
+ `Your message is too long (max ${CONVERSATIONS_MESSAGE_MAX_LENGTH.toLocaleString()} characters). Please shorten it or send it in multiple messages.`
+ )
+ return true
+ }
+ return false
+}
+
// Conversations tickets carry just the user's message (like the side panel composer), but for bug
// reports we still fold the exception in so it survives on email-channel tickets and when the
// agent's session-scoped exceptions panel can't resolve it. Mirrors how feature-preview feedback
@@ -783,9 +800,15 @@ export const supportLogic = kea<supportLogicType>([
// Conversations is where support is headed, so wait for the extension rather than racing
// it to the (temporary) Zendesk fallback
if (values.conversationsFlagEnabled && (await waitForConversations())) {
+ // Measure the full outgoing payload (message plus any appended exception) so the
+ // guard matches what the widget endpoint actually receives and rejects
+ const outgoingMessage = appendExceptionToMessage(message, exception_event)
+ if (warnIfMessageTooLong(outgoingMessage)) {
+ return
+ }
try {
const response = await posthog.conversations!.sendMessage(
- appendExceptionToMessage(message, exception_event),
+ outgoingMessage,
{ name: name || undefined, email: email || undefined },
true // every form submission starts a new ticket
)
diff --git a/products/conversations/backend/api/serializers.py b/products/conversations/backend/api/serializers.py
index bfee596b976e..bd0053ecc898 100644
--- a/products/conversations/backend/api/serializers.py
+++ b/products/conversations/backend/api/serializers.py
@@ -74,7 +74,7 @@ class WidgetMessageSerializer(WidgetAuthSerializer):
"""Serializer for incoming widget messages."""
distinct_id = serializers.CharField(required=False, max_length=400, help_text="PostHog distinct_id")
- message = serializers.CharField(required=True, max_length=5000, help_text="Message content")
+ message = serializers.CharField(required=True, max_length=10000, help_text="Message content")
traits = serializers.DictField(required=False, default=dict, help_text="Customer traits")
session_id = serializers.CharField(required=False, max_length=64, allow_null=True, help_text="PostHog session ID")
session_context = serializers.DictField(
diff --git a/products/conversations/backend/api/tests/test_widget.py b/products/conversations/backend/api/tests/test_widget.py
index 7d2194452a58..70338f4b83fb 100644
--- a/products/conversations/backend/api/tests/test_widget.py
+++ b/products/conversations/backend/api/tests/test_widget.py
@@ -534,7 +534,7 @@ class TestWidgetAPI(BaseTest):
response = self.client.post(
"/api/conversations/v1/widget/message",
{
- "message": "x" * 6000,
+ "message": "x" * 10001,
"widget_session_id": self.widget_session_id,
"distinct_id": self.distinct_id,
},
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
index 01424feabe32..5f1ad950f3aa 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
@@ -1,7 +1,7 @@
import { expectLogic } from 'kea-test-utils'
import posthog from 'posthog-js'
-import { supportLogic } from 'lib/components/Support/supportLogic'
+import { CONVERSATIONS_MESSAGE_MAX_LENGTH, supportLogic } from 'lib/components/Support/supportLogic'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -19,6 +19,9 @@ describe('sidepanelTicketsLogic', () => {
getTickets: jest.fn().mockResolvedValue({ results: [] }),
getMessages: jest.fn().mockResolvedValue({ messages: [], has_more: false }),
markAsRead: jest.fn().mockResolvedValue({}),
+ sendMessage: jest
+ .fn()
+ .mockResolvedValue({ ticket_id: 't1', ticket_status: 'open', created_at: '2026-07-21T00:00:00Z' }),
}
featureFlagLogic.mount()
featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.PRODUCT_SUPPORT_SIDE_PANEL]: true })
@@ -88,4 +91,24 @@ describe('sidepanelTicketsLogic', () => {
expect(logic.values.currentTicket?.id).toBe('ticket-1')
expect(supportLogic.values.pendingViewTicket).toBeNull()
})
+
+ it('blocks an over-limit message client-side but sends a normal one', async () => {
+ logic = sidepanelTicketsLogic.build()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ const send = (posthog as any).conversations.sendMessage
+
+ await expectLogic(logic, () => {
+ logic.actions.sendMessage('a short reply', jest.fn())
+ }).toFinishAllListeners()
+ expect(send).toHaveBeenCalledTimes(1)
+
+ await expectLogic(logic, () => {
+ logic.actions.sendMessage('a'.repeat(CONVERSATIONS_MESSAGE_MAX_LENGTH + 1), jest.fn())
+ }).toFinishAllListeners()
+ // still 1: the over-limit message is rejected before reaching the widget endpoint
+ expect(send).toHaveBeenCalledTimes(1)
+ expect(logic.values.messageSending).toBe(false)
+ })
})
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
index eca8f9b4e0a1..2ece602c7122 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
@@ -15,7 +15,7 @@ import { router } from 'kea-router'
import { subscriptions } from 'kea-subscriptions'
import posthog from 'posthog-js'
-import { appendExceptionToMessage, supportLogic } from 'lib/components/Support/supportLogic'
+import { appendExceptionToMessage, supportLogic, warnIfMessageTooLong } from 'lib/components/Support/supportLogic'
import { FEATURE_FLAGS } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -434,6 +434,9 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
if (!values.isEnabled || !content.trim() || values.messageSending || !posthog.conversations) {
return
}
+ if (warnIfMessageTooLong(content)) {
+ return
+ }
actions.setMessageSending(true)
try {
// If we're in "new" view, force creation of a new ticket