Skip to content

validation_mode warning showing up in production emails. #95

@sebaherrera07

Description

@sebaherrera07

I've recently upgraded all my gems, and suddenly I'm seeing this warning in emails in production environment:

You can also disable this overlay by setting config.validation_mode = :none in config/initializers/reactionview.rb.

Image

I asked some LLM and this is what it found (not sure if it is very accurate). Reporting it in case some adjustment needs to be done to the gem:

It turns out there actually isn't any HTML error in your mailers! The reason you're seeing this text in your emails comes down to how reactionview handles its validation overlays and how email clients handle modern HTML compared to normal web browsers.

I dug into the reactionview gem source code, and here is exactly what is happening:

1 - reactionview unconditionally injects a tag into your layouts
By default, the reactionview gem expects to operate in validation_mode = :overlay in both development and production (and :raise in test).

Because your mail layout (mailer.html.erb) lives under the /layouts/ directory, the gem intercepts it and automatically appends this exact HTML snippet to the rendering result (regardless of whether your HTML has actual errors or not)

2 - Why don't you see this in your web app's production environment?
In modern browsers (Chrome, Safari, Firefox), the element is specifically built to hold invisible content that the browser will not render until a JavaScript file activates it.

Because you correctly have config.debug_mode = Rails.env.development? configured in config/initializers/reactionview.rb, the gem's JavaScript isn't loaded in production. The gets injected into your site's DOM, but since the JS is missing, the browser safely ignores it and keeps it completely invisible.

3 - Why does it show up in production emails?
Email clients (Gmail, Outlook, Apple Mail) render HTML very differently than modern web browsers. They do not support modern HTML5 features like the tag.

When your email client processes the mailer's HTML, it defensively strips away the tag itself—but leaves the inner text intact and forces it to render right inline as visible text at the top of the email!

The Fix
To resolve this, you just need to disable the validation mode overlay outside of development in config/initializers/reactionview.rb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions