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

Error when processing controller action #732

Closed
vleonty opened this issue Oct 6, 2015 · 6 comments
Closed

Error when processing controller action #732

vleonty opened this issue Oct 6, 2015 · 6 comments

Comments

@vleonty
Copy link

vleonty commented Oct 6, 2015

I have one controller action that is throwing an error during processing. I am using ruby 2.1.2 and Brakeman 3.1.1. There are around 20+ controllers with a fair number of actions that all process without issue. A report is generated but brakeman exits in error.

I ran it in debug mode and got this call stack in the middle of the processing output:

Rendering backbone/index (["BackboneController#index"])
Error when processing backbone/index: Error when processing backbone/index: Error when processing backbone/index: undefined method `empty?' for nil:NilClass
/Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/processors/base_processor.rb:80:in `block in process_dstr'
(eval):3:in `map!'
(eval):3:in `map!'
/Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/processors/base_processor.rb:75:in `process_dstr'
/Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/ruby_parser/bm_sexp_processor.rb:75:in `block in process'
/Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/ruby_parser/bm_sexp_processor.rb:112:in `in_context'
/Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/ruby_parser/bm_sexp_processor.rb:71:in `process'
/Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/processors/template_processor.rb:24:in `process'
/Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/processors/base_processor.rb:79:in `block in process_dstr'

Then at the end of the run and following "Indexing call sites..":

Indexing call sites...        
/Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/ruby_parser/bm_sexp_processor.rb:69:in `process': Type should be a Symbol, not: [nil, nil] in {nil=>nil} (RuntimeError)
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/processors/lib/find_all_calls.rb:22:in `process_source'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/tracker.rb:182:in `block in index_call_sites'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/tracker.rb:110:in `block in each_template'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/tracker.rb:109:in `each'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/tracker.rb:109:in `each_template'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/tracker.rb:181:in `index_call_sites'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/scanner.rb:305:in `index_call_sites'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman/scanner.rb:65:in `process'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman.rb:327:in `scan'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/lib/brakeman.rb:62:in `run'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/gems/brakeman-3.1.1/bin/brakeman:78:in `<top (required)>'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/bin/brakeman:23:in `load'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/bin/brakeman:23:in `<main>'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/bin/ruby_executable_hooks:15:in `eval'
    from /Users/Me/.rvm/gems/ruby-2.1.2-v@myapp/bin/ruby_executable_hooks:15:in `<main>'

I can't quite figure out why the index action in this controller class is a problem. When I delete the action outright and then do a Brakeman run, it completes without any issue. Running 'ruby -c' and 'ruby_parse' run without any issue on this controller file.

@presidentbeef
Copy link
Owner

Sorry you having trouble.

The debug messages are not very clear, but it's not the controller action that's causing an issue, it's the backbone/index view. What kind of template is it?

@vleonty
Copy link
Author

vleonty commented Oct 6, 2015

Sorry, I understand that the debug messages may not be that clear and lack some degree of context. I thought it might be a reasonable starting point, and it is as much as I have to go on at this point.

It is a haml template.

@presidentbeef
Copy link
Owner

Oops I didn't mean to blame you for the unclear errors. Those are my fault :)

Unfortunately I can't replicate this issue without knowing the contents of the view. Is there any way you can either share the code or narrow it down to a sample that still causes the error?

@vleonty
Copy link
Author

vleonty commented Oct 7, 2015

No problem. I did some experimentation with the problem template and determined that it did not like an embedded comment that was under a javascript tag, I distilled it down to:

%body
    :javascript
        $(function() {
            #{
                # Ticket #9999
                # my variable needs to be number 4
             }
             var myVar = 4;
        });

@presidentbeef
Copy link
Owner

Perfect, I can reproduce the issue.

@presidentbeef
Copy link
Owner

Should be fixed with #750

Repository owner locked and limited conversation to collaborators Mar 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants