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

Fix exception when large object's class is anonymous #435

Merged
merged 3 commits into from
Feb 11, 2019

Conversation

kdiogenes
Copy link
Contributor

Avoids the error pointed by #411 (comment)

When a local/instance variable is anonymous and it's value is too large better_errors prints a default message in https://github.com/BetterErrors/better_errors/blob/master/lib/better_errors/error_page.rb#L111

This pull request adds a fallback to use obj.class.to_s, since obj.class.name returns nil for anonymous classes causing the following exception:

00:23:25 web.1      | Started POST "/admin/__better_errors/50c95030d470e258/variables" for ::1 at 2019-02-09 00:23:25 -0200
00:23:26 web.1      |   
00:23:26 web.1      | TypeError (no implicit conversion of nil into String):
00:23:26 web.1      |   
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:111:in `escapeHTML'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:111:in `rescue in inspect_value'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:107:in `inspect_value'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:94:in `block in render'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:93:in `each'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:93:in `render'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:30:in `eval'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:30:in `render'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/error_page.rb:37:in `do_variables'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/middleware.rb:137:in `internal_call'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/middleware.rb:75:in `better_errors_call'
00:23:26 web.1      | better_errors (2.5.0) lib/better_errors/middleware.rb:57:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:30:in `call'
00:23:26 web.1      | web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
00:23:26 web.1      | web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
00:23:26 web.1      | web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
00:23:26 web.1      | web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/railties/lib/rails/rack/logger.rb:38:in `call_app'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/railties/lib/rails/rack/logger.rb:26:in `block in call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/activesupport/lib/active_support/tagged_logging.rb:80:in `block in tagged'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/activesupport/lib/active_support/tagged_logging.rb:28:in `tagged'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/activesupport/lib/active_support/tagged_logging.rb:80:in `tagged'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/railties/lib/rails/rack/logger.rb:26:in `call'
00:23:26 web.1      | sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/request_id.rb:27:in `call'
00:23:26 web.1      | rack (2.0.6) lib/rack/method_override.rb:22:in `call'
00:23:26 web.1      | rack (2.0.6) lib/rack/runtime.rb:22:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/executor.rb:14:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/static.rb:126:in `call'
00:23:26 web.1      | rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/actionpack/lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
00:23:26 web.1      | webpacker (3.5.5) lib/webpacker/dev_server_proxy.rb:22:in `perform_request'
00:23:26 web.1      | rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
00:23:26 web.1      | /home/kadu/sources/rails-dev-box/rails/railties/lib/rails/engine.rb:524:in `call'
00:23:26 web.1      | puma (3.12.0) lib/puma/configuration.rb:225:in `call'
00:23:26 web.1      | puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
00:23:26 web.1      | puma (3.12.0) lib/puma/server.rb:472:in `process_client'
00:23:26 web.1      | puma (3.12.0) lib/puma/server.rb:332:in `block in run'
00:23:26 web.1      | puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
00:23:26 web.1      | Error occurred while parsing request parameters.
00:23:26 web.1      | Contents:
00:23:26 web.1      | 
00:23:26 web.1      |

@RobinDaugherty
Copy link
Member

Thanks for fixing this @cerdiogenes! I'm working to fix the CI builds on older Ruby versions, and I'll get your change merged and released ASAP.

@RobinDaugherty RobinDaugherty changed the title Fallbacks to to_s when obj class is anonymous Fix exception when large object's class is anonymous Feb 11, 2019
Just exclude the class name from the output completely. And improve spec example names. And fix capitalization of the frst sentence.
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 this pull request may close these issues.

None yet

2 participants