Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial incompatibility with rails 7.1 #121

Open
Intrepidd opened this issue Oct 25, 2023 · 2 comments · Fixed by rails/rails#53657
Open

Partial incompatibility with rails 7.1 #121

Intrepidd opened this issue Oct 25, 2023 · 2 comments · Fixed by rails/rails#53657

Comments

@Intrepidd
Copy link

I realised after upgrading to rails 7.1 that when I encounter an exception in the view, I do not get the familiar ActionDispatch::DebugExceptions page anymore, but rather my exceptions_app

After much digging, I realised there is a crash inside ActionDispatch::DebugExceptions when trying to display the backtrace, thus making the middleware not render the page, and the exception ends up getting caught by ActionDispatch::ShowExceptions down the road.

Here's the exception and the stacktrace :

eval error: undefined method `last' for nil:NilClass
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionview-7.1.1/lib/action_view/template/handlers/erb.rb:142:in `find_offset'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionview-7.1.1/lib/action_view/template/handlers/erb.rb:46:in `translate_location'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionview-7.1.1/lib/action_view/template.rb:229:in `translate_location'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.1.1/lib/action_dispatch/middleware/exception_wrapper.rb:258:in `spot'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.1.1/lib/action_dispatch/middleware/exception_wrapper.rb:302:in `extract_source'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.1.1/lib/action_dispatch/middleware/exception_wrapper.rb:206:in `block in source_extracts'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.1.1/lib/action_dispatch/middleware/exception_wrapper.rb:205:in `map'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.1.1/lib/action_dispatch/middleware/exception_wrapper.rb:205:in `source_extracts'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:126:in `create_template'
/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:78:in `render_for_browser_request'
  (rdbg)/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/actionpack-7.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:1:in `rescue in call'

better_html sounded like a good suspect, removing it from the bundle fixes the issue.

Alternatively, disabling runtime checks fixes the issue too :

BetterHtml.configure do |config|
  config.template_exclusion_filter = proc { true }
end

So it seems that the custom parser conflicts with the way rails 7.1 tries to extract the source.

@thomaswitt
Copy link

I also had a lot of bad experiences with the latest Rails version 7.2.2 and better html. No error page was displayed correctly anymore. Ended up in removing the gem completely.

@martinemde
Copy link

I submitted rails/rails#53657 that should resolve this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants