-
Notifications
You must be signed in to change notification settings - Fork 9
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
undefined method body
and code
for nil
#21
Comments
Hey @chaadow! I'm trying to reproduce it, but I cannot recreate a case when response is nil: even if I do |
Hi, faced the same problem test:
controller:
Or when the user wants access to a page without authorization, we redirect him to the auth page. Authorization via Devise gem. |
When using Devise for authorization and accessing a not authorized page, the Here is a request to a page that is not available to not signed in users: 29: def append_info_to_payload(payload)
30: super
31:
32: return unless monitors_action?(action_name)
33:
34: data = payload[IoMonitor::NAMESPACE] = {}
35:
36: aggregator.sources.each do |source|
37: data[source] = aggregator.get(source)
38: end
39:
40: binding.pry
=> 41: data[:response] = payload[:response].body.bytesize
42: end
[1] pry(#<Hub::TasksController>)> payload
=> {:controller=>"Hub::TasksController",
:action=>"index",
:request=>#<ActionDispatch::Request GET "http://localhost:3000/hub/tasks" for ::1>,
:params=>{"controller"=>"hub/tasks", "action"=>"index"},
:headers=>
#<ActionDispatch::Http::Headers:0x00007fba2960d1b0
@req=#<ActionDispatch::Request GET "http://localhost:3000/hub/tasks" for ::1>>,
:format=>:html,
:method=>"GET",
:path=>"/hub/tasks",
:view_runtime=>nil,
:db_runtime=>1.9763230085372925,
:io_monitor=>{:active_record=>489}} Here is also the [1] pry(#<Hub::TasksController>)> response
=> #<ActionDispatch::Response:0x00007fb9beb601f0
@cache_control={},
@committed=false,
@cv=
#<MonitorMixin::ConditionVariable:0x00007fba2987ed68
@cond=#<Thread::ConditionVariable:0x00007fba2987ed40>,
@monitor=#<Monitor:0x00007fba2987ede0>>,
@header=
{"X-Frame-Options"=>"SAMEORIGIN",
"X-XSS-Protection"=>"0",
"X-Content-Type-Options"=>"nosniff",
"X-Download-Options"=>"noopen",
"X-Permitted-Cross-Domain-Policies"=>"none",
"Referrer-Policy"=>"strict-origin-when-cross-origin"},
@mon_data=#<Monitor:0x00007fba2987ede0>,
@mon_data_owner_object_id=222560,
@request=#<ActionDispatch::Request GET "http://localhost:3000/hub/tasks" for ::1>,
@sending=false,
@sent=false,
@status=200,
@stream=
#<ActionDispatch::Response::Buffer:0x00007fb9be755fb0
@buf=[],
@closed=false,
@response=#<ActionDispatch::Response:0x00007fb9beb601f0 ...>,
@str_body=nil>> If we stub this [2] pry(#<Hub::TasksController>)> payload[:response]={"body" => {"bytesize"=>1}}
=> {"body"=>{"bytesize"=>1}}
[3] pry(#<Hub::TasksController>)>
Completed 401 Unauthorized in 231635ms (ActiveRecord: 2.0ms | ActiveRecord Payload: 489 Bytes | Response Payload: 1 Byte | Allocations: 1444774)
Started GET "/users/sign_in" for ::1 at 2023-06-26 17:47:24 +0600
Processing by UsersDevise::SessionsController#new as HTML
Rendering layout layouts/public/application.html.slim
Rendering devise/sessions/new.html.slim within layouts/public/application
Rendered shared/_notification.html.slim (Duration: 0.4ms | Allocations: 165)
Rendered devise/sessions/new.html.slim within layouts/public/application (Duration: 3.4ms | Allocations: 1877)
Rendered public/application/_favicon.html.slim (Duration: 0.2ms | Allocations: 16)
Rendered layouts/public/_navbar.html.slim (Duration: 1.6ms | Allocations: 1332)
Rendered shared/_footer_social_links.html.slim (Duration: 0.2ms | Allocations: 263)
Rendered layouts/public/_footer.html.slim (Duration: 0.9ms | Allocations: 802)
Rendered layout layouts/public/application.html.slim (Duration: 11.7ms | Allocations: 7974)
From: /home/grfork/playground/ruby/io_monitor/lib/io_monitor/controller.rb:41 IoMonitor::Controller#append_info_to_payload:
29: def append_info_to_payload(payload)
30: super
31:
32: return unless monitors_action?(action_name)
33:
34: data = payload[IoMonitor::NAMESPACE] = {}
35:
36: aggregator.sources.each do |source|
37: data[source] = aggregator.get(source)
38: end
39:
40: binding.pry
=> 41: data[:response] = payload[:response].body.bytesize
42: end
[1] pry(#<UsersDevise::SessionsController>)> payload[:response].body.bytesize
=> 9139 then it returns 401 and initiates the next response that has |
Reproduced this issue with this code: class GraphqlController < ApplicationController
def execute
raise StandardError
end
end After CURLing GQL endpoint got this:
This is how looks
|
Hi ! What's the status of this issue ? |
I believe since the response is nil.. then open-uri tries to call
resp.code
which does not workThe text was updated successfully, but these errors were encountered: