Haml: ActionView::Template::Error (Unsupported callback code)

Created on 26 Jul 2017  ·  17Comments  ·  Source: haml/haml

I've updated HAML to 5.0.1 as part of ongoing work to port our Rails app from 5.0.2 to 5.1.2 (previous HAML version was 4.0.7).

I was seeing a deprecation warning regarding Erubis/Erubi, hence upgrading HAML:

DEPRECATION WARNING: ActionView::Template::Handlers::Erubis is deprecated and will be removed from Rails 5.2. Switch to ActionView::Template::Handlers::ERB::Erubi instead. (called from <top (required)> at /Users/sean/src/datacentred/stronghold/config/application.rb:7)

Now I'm met with this strange error when I try to log into our app:

Started GET "/sign_in?next=%2F" for ::1 at 2017-07-26 15:39:46 +0100
   (0.3ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
   (0.3ms)  SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
Processing by SessionsController#new as HTML
  Parameters: {"next"=>"/"}
  Rendering sessions/new.html.haml within layouts/customer-sign-up
  Rendered sessions/new.html.haml within layouts/customer-sign-up (10.0ms)
Completed 500 Internal Server Error in 29ms (ActiveRecord: 0.0ms)



ActionView::Template::Error (Unsupported callback code):

Here is the contents of sessions.new.html.haml:

- title "Sign In"

%h3 Sign In

= display_flash

= form_for(User.new, :url => sessions_path, :method => :post, :html => {:role => 'form'}) do |f|
  = hidden_field_tag :next, params[:next]
  .form-group
    = f.email_field :email, :class => "form-control",
                    :id => "inputEmail", :placeholder => "Email address", :autofocus => ''
  .form-group
    = f.password_field :password, :class => "form-control wink-password",
                       :id => "inputPassword", :placeholder => "Password"
  = f.submit 'Sign In', :class => 'btn btn-primary', style: 'width: 100%; margin-bottom: 10px'
  .pull-right
    = link_to 'Reset Password', new_reset_path
    |
    = link_to 'Create Account', create_signup_path
  %p= link_to 'Trouble logging in?', ExternalLinks.cookie_documentation_path

If I change the contents of the template new.html.haml to the text "Hello" then I get this error:

ActionView::Template::Error (Unsupported callback static)

I've spent a few hours trying to find anything helpful online regarding this, but so far I've seen nothing.

Any clues what may be going on here?

Most helpful comment

The issue was that the clock.rb files content was not 'namespaced':

include Clockwork
every(1.hour, ...
...

After moving it under the module the problem was solved:

module Clockwork
  every(1.hour, ...
end

I closed the issues on temple and clockwork 👍

All 17 comments

We can't help without error backtrace. We even don't have which line is wrong in your template. Set logl_level = debug first if you don't, then please put full log of the failed request.

And if you can't create error backtrace, please create reproductive repository with minimum requirements.

The log level is already set at debug. I haven't edited that backtrace at all so it's odd that there's clearly lines missing from it.

I see. Then we need reproductive environment to help you.

Only Gemfile can't reproduce a problem. I'm waiting for "reproductive repository with minimum requirements". Do you think really all these gems are necessary to reproduce it?

Without error backtrace, things are very difficult to solve. So we need your effort to share your environment. Otherwise we can never resolve this.

I appreciate that @k0kubun but I'm working on a commercial project and I can't share the code.

I've tried to reproduce the issue in a new repository and I had no luck - I just can't get it to reproduce. I will continue attempting to debug it in our codebase and post an update here if I discover the root cause. Or perhaps others will find this issue if they see similar problems elsewhere.

In the meantime, I guess there's nothing to do but close this issue for now.

I've had the same problem... will try to replicate..

Possibly it's the same as https://github.com/haml/haml/issues/946. Please try master branch.

It raises SyntaxError and your error is not related to this issue, right?

Like this:

SyntaxError (/Users/kokubun/src/github.com/staycreativedesign/haml_errors/app/views/invoices/index.haml:5: syntax error, unexpected keyword_ensure, expecting keyword_end
...:Util.html_safe(_erbout);ensure;@haml_buffer = @haml_buffer....
...                               ^
/Users/kokubun/src/github.com/staycreativedesign/haml_errors/app/views/invoices/index.haml:8: syntax error, unexpected end-of-input, expecting keyword_end):

It seems that Haml compiler bug with empty each loop

Correct... :) sorry its not the same bug?

On Tue, Aug 29, 2017 at 10:13 PM, Takashi Kokubun notifications@github.com
wrote:

It seems that Haml compiler bug with empty each loop


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/haml/haml/issues/944#issuecomment-325867352, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AB3L0gGxvpIe0a6eKfRbT3PyatvMV_Bqks5sdNNkgaJpZM4OkBtu
.

Yeah, anyway reproductive repository was very helpful to identify it. Thanks :)

Filed: https://github.com/haml/haml/issues/954

I am having this same issue, this is the stack trace I'm seeing

RuntimeError:
       Unsupported callback newline
gems/clockwork-2.0.2/lib/clockwork/manager.rb:44:in `on'
gems/clockwork-2.0.2/lib/clockwork.rb:38:in `on'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:86:in `dispatcher'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `block in on_multi'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `each'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:7:in `on_multi'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:82:in `dispatcher'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:49:in `compile'
gems/temple-0.8.0/lib/temple/mixins/dispatcher.rb:45:in `call'
gems/temple-0.8.0/lib/temple/engine.rb:50:in `block in call'
gems/temple-0.8.0/lib/temple/engine.rb:50:in `each'
gems/temple-0.8.0/lib/temple/engine.rb:50:in `inject'
gems/temple-0.8.0/lib/temple/engine.rb:50:in `call'
gems/haml-5.0.4/lib/haml/temple_engine.rb:41:in `compile'
gems/haml-5.0.4/lib/haml/engine.rb:61:in `initialize'

Thanks for the backtrace. It was much helpful than the original report.

And it seems that it's raised in clockwork.gem. https://github.com/Rykian/clockwork/blob/v2.0.2/lib/clockwork/manager.rb#L44

Also, if Clockwork is included on the top-level, it seems to break temple.gem's behavior. I think both clockwork and temple can do better, and at least the place to report the issue is not here (haml repository) because it should happen on slim too.

Thanks @k0kubun i opened tickets on temple and clockwork

https://github.com/judofyr/temple/issues/118
https://github.com/Rykian/clockwork/issues/39

In case anybody wants to follow up

The issue was that the clock.rb files content was not 'namespaced':

include Clockwork
every(1.hour, ...
...

After moving it under the module the problem was solved:

module Clockwork
  every(1.hour, ...
end

I closed the issues on temple and clockwork 👍

Was this page helpful?
0 / 5 - 0 ratings