You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating my Gems, I get this error in my Rspec tests that produce requests:
$ util/rspec.sh spec/requests/export_api/v1/clients_spec.rb
Running via Spring preloader in process 3443
[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See https://github.com/wspurgin/rspec-sidekiq/wiki/FAQ-&-Troubleshooting
2024-07-03T11:22:07.875Z pid=3443 tid=50z INFO: Sidekiq 7.3.0 connecting to Redis with options {:size=>10, :pool_name=>"internal", :url=>"redis://redis:6379/0"}
F
Failures:
1) ExportApi::V1::Clients fetching clients as JSON GET /export_api/v1/clients returns the clients
Failure/Error: super(path, **kwarg)
NoMethodError:
undefined method `read' for nil:NilClass
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm/context_builder.rb:82:in `get_body'
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm/context_builder.rb:51:in `apply_to_request'
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm/context_builder.rb:34:in `block in build'
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm/context_builder.rb:33:in `build'
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm/agent.rb:235:in `build_context'
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm.rb:323:in `build_context'
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm/middleware.rb:40:in `rescue in call'
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm/middleware.rb:37:in `call'
# /usr/local/bundle/ruby/3.2.0/gems/rack-cors-2.0.2/lib/rack/cors.rb:102:in `call'
# /usr/local/bundle/ruby/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:536:in `call'
# /usr/local/bundle/ruby/3.2.0/gems/rack-test-2.1.0/lib/rack/test.rb:360:in `process_request'
# /usr/local/bundle/ruby/3.2.0/gems/rack-test-2.1.0/lib/rack/test.rb:153:in `request'
# ./spec/support/json_formattable.rb:14:in `block in <module:ModifiedAcceptHeaders>'
# ./spec/requests/export_api/v1/clients_spec.rb:13:in `block (4 levels) in <main>'
# ./spec/rails_helper.rb:106:in `block (3 levels) in <main>'
# /usr/local/bundle/ruby/3.2.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/strategy.rb:30:in `cleaning'
# /usr/local/bundle/ruby/3.2.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:34:in `block (2 levels) in cleaning'
# /usr/local/bundle/ruby/3.2.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:35:in `cleaning'
# ./spec/rails_helper.rb:105:in `block (2 levels) in <main>'
# /usr/local/bundle/ruby/3.2.0/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `load'
# /usr/local/bundle/ruby/3.2.0/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call'
# /usr/local/bundle/ruby/3.2.0/gems/spring-4.2.1/lib/spring/command_wrapper.rb:38:in `call'
# /usr/local/bundle/ruby/3.2.0/gems/spring-4.2.1/lib/spring/application.rb:226:in `block in serve'
# /usr/local/bundle/ruby/3.2.0/gems/spring-4.2.1/lib/spring/application.rb:190:in `fork'
# /usr/local/bundle/ruby/3.2.0/gems/spring-4.2.1/lib/spring/application.rb:190:in `serve'
# /usr/local/bundle/ruby/3.2.0/gems/spring-4.2.1/lib/spring/application.rb:153:in `block in run'
# /usr/local/bundle/ruby/3.2.0/gems/spring-4.2.1/lib/spring/application.rb:147:in `loop'
# /usr/local/bundle/ruby/3.2.0/gems/spring-4.2.1/lib/spring/application.rb:147:in `run'
# /usr/local/bundle/ruby/3.2.0/gems/spring-4.2.1/lib/spring/application/boot.rb:25:in `<top (required)>'
# -e:1:in `<main>'
# ------------------
# --- Caused by: ---
# NoMethodError:
# undefined method `read' for nil:NilClass
# /usr/local/bundle/ruby/3.2.0/gems/elastic-apm-4.7.3/lib/elastic_apm/context_builder.rb:82:in `get_body'
Steps to reproduce
Hard to reproduce from scratch … but I can provide the exact request data which shows that the body is indeed nil. When I dump the req object in the get_body function, you can see it has no body:
My backtrace shows a middleware (json_formattable.rb) as the last internal source of the error, but the error persistts when I comment out that middleware, so it is not at fault.
Per the discussion here, I would think that elastic-apm simply needs to handle the body being nil with Rack ≥3.1.0?
Describe the bug
After updating my Gems, I get this error in my Rspec tests that produce requests:
Steps to reproduce
Hard to reproduce from scratch … but I can provide the exact request data which shows that the body is indeed
nil
. When I dump thereq
object in theget_body
function, you can see it has nobody
:Expected behavior
The tests should pass.
Environment
Additional context
My backtrace shows a middleware (
json_formattable.rb
) as the last internal source of the error, but the error persistts when I comment out that middleware, so it is not at fault.Per the discussion here, I would think that elastic-apm simply needs to handle the
body
beingnil
with Rack ≥3.1.0?Here is the exact Gemfile.lock diff:
The text was updated successfully, but these errors were encountered: