Markdown ERB templates not working when upgrading from 7.0.8.6

We use markdown templates for our action mailer messages. These have worked fine up through the versions but for some reason, they have stopped working in any 7.1 version. My rspec tests for the mailer work fine using rails 7.0.8.6 and fail using anything higher. I have tried 7.1.0.beta, 7.1.0, 7.1.3, and 7.1.5 and they all fail. If I change the templates in app/views/user_mailer to all be .text.erb and also change the app/views/layouts/mailer.md.erb to .text.erb then they work fine under 7.1. I assume changing them to html would work but I haven’t tried.

This is the error I get:

     Failure/Error: Kespry Cloud is an aerial intelligence platform which allows you to gain insights from drone data.
     
     ActionView::Template::Error:
       undefined method `valid_encoding?' for #<ActionView::OutputBuffer:0x00007f2821296c10 @raw_buffer="Kespry Cloud is an aerial intelligence platform which allows you to gain insights from drone data. \nMeasure areas and volumes, analyze high resolution images, and automatically generate reports for \ninternal business decisions or regulatory audits.\n">
     # ./app/views/user_mailer/_invite_info.md.erb:1:in `_app_views_user_mailer__invite_info_md_erb___911296744252825811_30780'
     # ./app/mailers/user_mailer.rb:27:in `inform_invite'
     # ./spec/mailers/user_mailer_spec.rb:50:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # NoMethodError:
     #   undefined method `valid_encoding?' for #<ActionView::OutputBuffer:0x00007f2821296c10 @raw_buffer="Kespry Cloud is an aerial intelligence platform which allows you to gain insights from drone data. \nMeasure areas and volumes, analyze high resolution images, and automatically generate reports for \ninternal business decisions or regulatory audits.\n">
     #   ./app/views/user_mailer/_invite_info.md.erb:1:in `_app_views_user_mailer__invite_info_md_erb___911296744252825811_30780'

The file _invite_info.md.erb contains only text, no variable references, no markdown, etc. It is included from the inform_invite.md.erb like this:

<%= @invite.inviter.name %> (<%= @invite.inviter.email %>) has invited you to access drone data
of the site [<%= @invite.site.name %>](<%= invite_url(@invite.token) %>)
in Kespry Cloud.

<%= render "invite_info" %>

I tried rendering just the _invite_info.md.erb directly using

    invite_info = render_to_string(template: 'user_mailer/_invite_info', locals: {  })

and I get the same error. I’ve searched through the change logs and I don’t see anything that indicates this failure to be expected. Any idea what could be causing this?