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

Regression with 3.21.0 and render_inline #2187

Closed
tvdeyen opened this issue Dec 20, 2024 · 4 comments
Closed

Regression with 3.21.0 and render_inline #2187

tvdeyen opened this issue Dec 20, 2024 · 4 comments

Comments

@tvdeyen
Copy link

tvdeyen commented Dec 20, 2024

Steps to reproduce

See this failed CircleCI run of Solidus https://app.circleci.com/pipelines/github/solidusio/solidus/7226/workflows/289fdaa9-334f-4c14-ad3c-0af8222f7da9/jobs/67674

The Component Spec can be found at https://github.com/solidusio/solidus/blob/main/admin/spec/components/solidus_admin/base_component_spec.rb#L14

The component can be found at https://github.com/solidusio/solidus/blob/main/admin/app/components/solidus_admin/base_component.rb

Expected behavior

Test does not fail with syntax error

Actual behavior

Test does fails with syntax error

Backtrace:

SyntaxError:
       /home/circleci/solidus/vendor/bundle/ruby/3.1.0/gems/view_component-3.21.0/lib/view_component/compiler.rb:98: syntax error, unexpected local variable or method, expecting '}'
       ...in <top (required)>') component rendered HTML-unsafe output....
       ...                      ^~~~~~~~~
       /home/circleci/solidus/vendor/bundle/ruby/3.1.0/gems/view_component-3.21.0/lib/view_component/compiler.rb:98: syntax error, unexpected local variable or method, expecting `do' or '{' or '('
       ...ent rendered HTML-unsafe output. The output will be automati...
       ...                         ^~~~~~
       /home/circleci/solidus/vendor/bundle/ruby/3.1.0/gems/view_component-3.21.0/lib/view_component/compiler.rb:98: syntax error, unexpected local variable or method, expecting `do' or '{' or '('
       ... automatically escaped, but you may want to investigate.') } 
       ...                            ^~~
       /home/circleci/solidus/vendor/bundle/ruby/3.1.0/gems/view_component-3.21.0/lib/view_component/compiler.rb:98: syntax error, unexpected string literal
       ...t you may want to investigate.') } 
       ...                              ^
       /home/circleci/solidus/vendor/bundle/ruby/3.1.0/gems/view_component-3.21.0/lib/view_component/compiler.rb:99: unterminated string meets end of file
             end
                ^
       /home/circleci/solidus/vendor/bundle/ruby/3.1.0/gems/view_component-3.21.0/lib/view_component/compiler.rb:99: syntax error, unexpected end-of-input, expecting `end'
             end

System configuration

Rails version:

7.0, 7.1, 7.2

Ruby version:

3.1, 3.2, 3.3

Gem version:

3.21.0

It works with 3.20.0

@joelhawksley
Copy link
Member

joelhawksley commented Dec 20, 2024

@tvdeyen interesting! Do you have time to open a failing test here for this use case? I do see that you are getting the HTML safety warning that we improved in 3.21, so I'm wondering if that's part of the issue.

@mamhoff
Copy link

mamhoff commented Jan 3, 2025

@joelhawksley I hope you're well! It looks like the compiler is under some circumstances trying to eval the warning. We've tried getting to the core of the issue but admittedly got a bit lost in the metaprogramming...

@mamhoff
Copy link

mamhoff commented Jan 3, 2025

After some investigation, we found the problem was with a mocked component that was an anonymous class. This made render_inline fail with

.gem/ruby/3.2.6/gems/view_component-3.21.0/lib/view_component/base.rb:94:in `render_in': undefined method `variants' for nil:NilClass (NoMethodError)

      @__vc_variant ||= @lookup_context.variants.first
                                       ^^^^^^^^^

This error message then went into the compiler, and the error message was the unsafe HTML.

I would close this for now, as we've found a workaround in solidusio/solidus#6055.

@tvdeyen
Copy link
Author

tvdeyen commented Jan 3, 2025

Thanks @mamhoff for investigating. Closing

@tvdeyen tvdeyen closed this as completed Jan 3, 2025
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

No branches or pull requests

3 participants