Closed DhawalSawla closed 1 year ago
It results in the same error for the stoplight gem version 2.2.1
.
You use Stoplight syntax that is not compatible with your Stoplight version. I suggest you use the latest Stoplight version (4.1). If, for some reason, you cannot use Stoplight 4.1, you need to rewrite your example the following way:
- light = Stoplight('http-api')
+ light = Stoplight('http-api') { 22.0 / 7 }
- light.run { 22.0 / 7 }
+ light.run
You can find more details in the update guide https://github.com/bolshakov/stoplight/blob/master/UPGRADING.md
Thanks! The above code works. I still get below error when I add around_action
method to my controller.
stoplight
#<Proc:0x00007fcd525f7f90 /Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/callbacks.rb:106>
health_checks#mobile_ready
Stoplight Error: ["/Users/thewall/.gem/ruby/3.0.0/gems/stoplight-3.0.1/lib/stoplight/light/runnable.rb:56:in `run_code'", "/Users/thewall/.gem/ruby/3.0.0/gems/stoplight-3.0.1/lib/stoplight/light/runnable.rb:35:in `run_green'", "/Users/thewall/.gem/ruby/3.0.0/gems/stoplight-3.0.1/lib/stoplight/light/runnable.rb:23:in `run'", "/Users/thewall/Downloads/Work/projects/k2web/app/controllers/health_checks_controller.rb:166:in `stoplight'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/callbacks.rb:121:in `block in run_callbacks'", "/Users/thewall/.gem/ruby/3.0.0/gems/actiontext-6.0.5.1/lib/action_text/rendering.rb:19:in `with_renderer'", "/Users/thewall/.gem/ruby/3.0.0/gems/actiontext-6.0.5.1/lib/action_text/engine.rb:55:in `block (4 levels) in <class:Engine>'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/callbacks.rb:121:in `instance_exec'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/callbacks.rb:121:in `block in run_callbacks'", "/Users/thewall/.gem/ruby/3.0.0/gems/marginalia-1.11.1/lib/marginalia.rb:109:in `record_query_comment'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/callbacks.rb:121:in `block in run_callbacks'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/callbacks.rb:139:in `run_callbacks'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/abstract_controller/callbacks.rb:41:in `process_action'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_controller/metal/rescue.rb:22:in `process_action'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/notifications.rb:180:in `block in instrument'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/notifications.rb:180:in `instrument'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_controller/metal/instrumentation.rb:32:in `process_action'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'", "/Users/thewall/.gem/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/railties/controller_runtime.rb:27:in `process_action'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/abstract_controller/base.rb:136:in `process'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionview-6.0.5.1/lib/action_view/rendering.rb:39:in `process'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_controller/metal.rb:190:in `dispatch'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_controller/metal.rb:254:in `dispatch'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/routing/route_set.rb:33:in `serve'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/journey/router.rb:49:in `block in serve'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/journey/router.rb:32:in `each'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/journey/router.rb:32:in `serve'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/routing/route_set.rb:834:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/omniauth-2.0.4/lib/omniauth/strategy.rb:202:in `call!'", "/Users/thewall/.gem/ruby/3.0.0/gems/omniauth-2.0.4/lib/omniauth/strategy.rb:169:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/bullet-6.1.0/lib/bullet/rack.rb:15:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/i18n-1.14.1/lib/i18n/middleware.rb:11:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-cors-1.1.1/lib/rack/cors.rb:100:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/config.rb:19:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/warden-1.2.8/lib/warden/manager.rb:36:in `block in call'", "/Users/thewall/.gem/ruby/3.0.0/gems/warden-1.2.8/lib/warden/manager.rb:34:in `catch'", "/Users/thewall/.gem/ruby/3.0.0/gems/warden-1.2.8/lib/warden/manager.rb:34:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb:15:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/etag.rb:27:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/conditional_get.rb:27:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:266:in `context'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:260:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/cookies.rb:654:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:567:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'", "/Users/thewall/.gem/ruby/3.0.0/gems/activesupport-6.0.5.1/lib/active_support/callbacks.rb:101:in `run_callbacks'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/executor.rb:14:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rollbar-2.25.0/lib/rollbar/middleware/rails/rollbar.rb:25:in `block in call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rollbar-2.25.0/lib/rollbar.rb:145:in `scoped'", "/Users/thewall/.gem/ruby/3.0.0/gems/rollbar-2.25.0/lib/rollbar/middleware/rails/rollbar.rb:22:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/better_errors-2.9.1/lib/better_errors/middleware.rb:87:in `protected_app_call'", "/Users/thewall/.gem/ruby/3.0.0/gems/better_errors-2.9.1/lib/better_errors/middleware.rb:82:in `better_errors_call'", "/Users/thewall/.gem/ruby/3.0.0/gems/better_errors-2.9.1/lib/better_errors/middleware.rb:60:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rollbar-2.25.0/lib/rollbar/middleware/rails/show_exceptions.rb:22:in `call_with_rollbar'", "/Users/thewall/.gem/ruby/3.0.0/gems/web-console-3.7.0/lib/web_console/middleware.rb:135:in `call_app'", "/Users/thewall/.gem/ruby/3.0.0/gems/web-console-3.7.0/lib/web_console/middleware.rb:30:in `block in call'", "/Users/thewall/.gem/ruby/3.0.0/gems/web-console-3.7.0/lib/web_console/middleware.rb:20:in `catch'", "/Users/thewall/.gem/ruby/3.0.0/gems/web-console-3.7.0/lib/web_console/middleware.rb:20:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/lograge-0.11.2/lib/lograge/rails_ext/rack/logger.rb:15:in `call_app'", "/Users/thewall/.gem/ruby/3.0.0/gems/railties-6.0.5.1/lib/rails/rack/logger.rb:26:in `block in call'", "/Users/thewall/Downloads/Work/projects/k2web/lib/kt_logging.rb:15:in `block in tagged'", "/Users/thewall/Downloads/Work/projects/k2web/lib/kt_logging.rb:8:in `block_tagged'", "/Users/thewall/Downloads/Work/projects/k2web/lib/kt_logging.rb:15:in `tagged'", "/Users/thewall/.gem/ruby/3.0.0/gems/railties-6.0.5.1/lib/rails/rack/logger.rb:26:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/request_store-1.5.0/lib/request_store/middleware.rb:19:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/method_override.rb:24:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/executor.rb:14:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/static.rb:126:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/rack-2.2.4/lib/rack/sendfile.rb:110:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/actionpack-6.0.5.1/lib/action_dispatch/middleware/host_authorization.rb:103:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/railties-6.0.5.1/lib/rails/engine.rb:527:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/railties-6.0.5.1/lib/rails/railtie.rb:190:in `public_send'", "/Users/thewall/.gem/ruby/3.0.0/gems/railties-6.0.5.1/lib/rails/railtie.rb:190:in `method_missing'", "/Users/thewall/.gem/ruby/3.0.0/gems/puma-6.0.2/lib/puma/configuration.rb:268:in `call'", "/Users/thewall/.gem/ruby/3.0.0/gems/puma-6.0.2/lib/puma/request.rb:93:in `block in handle_request'", "/Users/thewall/.gem/ruby/3.0.0/gems/puma-6.0.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'", "/Users/thewall/.gem/ruby/3.0.0/gems/puma-6.0.2/lib/puma/request.rb:92:in `handle_request'", "/Users/thewall/.gem/ruby/3.0.0/gems/puma-6.0.2/lib/puma/server.rb:429:in `process_client'", "/Users/thewall/.gem/ruby/3.0.0/gems/puma-6.0.2/lib/puma/server.rb:232:in `block in run'", "/Users/thewall/.gem/ruby/3.0.0/gems/puma-6.0.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'", "/Users/thewall/.gem/ruby/3.0.0/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'"]
The code SS is below:
All right, I have confused you with this backward incompatible change.
I released v3.0.2, which shows a better error message in such cases. let me know if you have any further questions
Describe the bug
When I run this small code below:
it leads to the below error: /Users/thewall/.gem/ruby/3.0.0/gems/stoplight-3.0.1/lib/stoplight/light/runnable.rb:56:in
run_code': undefined method
call' for nil:NilClass (NoMethodError)To Reproduce Steps to reproduce the behavior.
Expected behavior I expected the above method to run properly without giving any error.
Screenshots
I added the gem in my gemfile like this:
gem 'stoplight'
I also see it in my gemfile.lock:
stoplight (3.0.1)
Environment (please complete the following information):
Additional context Add any other context about the problem here.