This was originally incorrectly posted at https://github.com/rails/rails/issues/28072 - as advised, I’m now posting it here instead.
It is very easy to accidentally call content_for from within a block that will be fragment cached, especially if the cached fragment calls out to a partial. eg:
<%= cache “fragment” do %>
<% end %>