Gmail collapses MR notifications when anti-trimming markers collide
Summary
On GitLab.com, Gmail collapses entire merged notifications behind an ellipsis, including the merge status and navigation/unsubscribe links.
Inspection of two delivered notifications confirms that the existing anti-trimming marker can collide when notifications for the same MR are rendered within one second.
Observed setup
- Two GitLab accounts receive notifications for the same MR.
- One notification reaches a Gmail mailbox directly.
- The other reaches a Google Group that redistributes it to the same mailbox.
- Both notifications are generated within one second.
- Gmail collapses the later copy in the conversation.
This describes the observed delivery sequence; a controlled reproduction remains to be performed.
Evidence
Two downloaded notifications for this merge request both have the date 2026-09-22 12:37:06 UTC.
They have different Message-IDs and recipient-specific unsubscribe/reply tokens, but identical visible content and the same hidden marker:
Notification message regarding https://gitlab.com/gitlab-org/gitlab/-/merge_requests/256867 at 1790080626The marker survived delivery in both HTML bodies. The notification template generates it using the target URL and Time.current.to_i.
This confirms the uniqueness flaw and is consistent with Gmail detecting repeated content. It does not yet establish that changing the marker prevents folding.
Expected behavior
The merge status and view/unsubscribe links remain visible without expanding trimmed content.
Proposed fix and verification
- Replace the timestamp with a per-render random value, such as
SecureRandom.hex(16), initially preserving the marker’s placement and styling. - Add a regression test rendering notifications for two recipients of the same MR under frozen time. Verify different markers and preserved visible content and recipient-specific links.
- Compare existing and randomized markers in a Gmail conversation with direct and Google Group delivery. Rendering tests alone cannot verify Gmail’s behavior.
- Use synthetic fixtures rather than raw downloaded messages.
Approval notifications were also reported collapsed. Their mailer layout lacks the marker; investigate this related coverage gap separately.
Follow-up: approval and auto-merge notifications
Approval, unapproval and auto-merge notifications use the mailer layout (app/views/layouts/mailer.html.haml), which has no marker. On 2026-10-01 in Gmail, the second of two approval notifications in one MR thread hid its details and "View merge request" action behind the trimmed-content ellipsis. This issue is reopened to cover this case.
Fix: Add random marker to mailer layout