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
Exception in ERB template does not render exception view properly #48173
Comments
cc @tenderlove. I'm not very familiar with this code, but the parser very clearly give up by raising Such raw I suspect there are two fixes needed here:
I'll have a quick look at the second part of the fix. |
Fix: rails#48173 If for some reason the column identification fails, we should fallback to the old error rendering with only line information.
Brief comment to say that I'm seeing this constantly on my 7.1 apps and it's a huge PITA. |
Text tokens may be conditionally appended to the output buffer. For example if we have a template like this: ```erb <h1>Oh no!</h1> This template has a runtime error <b> <% if true %> <%= method_that_does_not_exist %> <% end %> </b> Yikes! ``` In the above case, a string literal (`" "`) will be conditionally appended to the output buffer with some code like below: ```ruby @output_buffer.safe_append=' '.freeze ``` This commit teaches text tokens (string literals) to scan forward in the compiled template until it finds the literal, thereby skipping the code generated for appending to the output buffer. Related to: * Bug: rails#48173 * PR: rails#48184
We've noticed that any error within the ERB template does not handle the error the same way as the error coming from controller. After some debugging, I noticed that there's an error thrown within
create_template
call. From there, I found this PR that touched the relevant section. And validated the behavior with modified test below.Steps to reproduce
I've changed the test scenario here to wrap the error case with noop if-statement, which should not change the behavior.
It changes the file
actionview/test/fixtures/test/runtime_error.html.erb
toThis is used by the test
actionview/test/template/render_test.rb
Your reproduction script goes here
After making the above change (or checkout this fork), run
Expected behavior
The test should pass
Actual behavior
Test fails with error
System configuration
Rails version:
main
Ruby version:
3.2
The text was updated successfully, but these errors were encountered: