Gmail connector rejects valid threaded reply with "Subject does not match"
Summary
The Gmail connector can fail to send a threaded reply via _send_email with reply_message_id, returning Failed to build message payload / Subject does not match, even when the supplied subject appears to match the visible Gmail thread subject.
This looks like a connector-side subject validation or normalization issue rather than a Gmail authentication/problem, because Gmail search, thread read, and a non-threaded send all worked in the same session.
What happened
- Searched Gmail for an existing conversation.
- Read the thread and selected the latest message ID as
reply_message_id. - Called
_send_emailwithreply_message_id, recipient, body, and the visible reply subject. - Connector failed before sending:
GmailConnectorError: Failed to send email: {'error': 'Failed to build message payload', 'detail': 'Subject does not match'}
- Retried with the visible non-
Re:subject form from the existing sent message in the same conversation. - Got the same
Subject does not matcherror. - Sent the same message body as a new email without
reply_message_id; that succeeded immediately.
Expected behavior
When reply_message_id points at a valid Gmail message in a readable thread, _send_email should either:
- accept normalized subject variants such as
Re: <subject>vs<subject>, and common bracketed ticket prefixes, or - rely on Gmail reply headers/thread IDs instead of rejecting locally on a strict subject comparison.
Actual behavior
The connector rejected the reply before send with Subject does not match, forcing a new unthreaded email as a workaround.
User impact
The workaround sends a separate email instead of replying inline, which can route to a different support representative and lose conversation continuity.
Privacy note
All account names, email addresses, ticket IDs, subjects, and message contents from the original case have been intentionally omitted or generalized. The only included error text is the connector error itself.