bullet
bullet copied to clipboard
Bullet raises the error on a Grape API endpoint with status: :no_content (204)
The error:
undefined method `empty?' for 204:Integer excluded from capture: No host specified, no public_key specified, no project_id specified
app |
app | NoMethodError (undefined method `empty?' for 204:Integer):
app |
app | bullet (6.1.0) lib/bullet/rack.rb:44:in `empty?'
app | bullet (6.1.0) lib/bullet/rack.rb:20:in `call'
The response is done in the Grape api:
status :no_content
Seems bullet can't handle the empty response correctly
May I ask how you configure bullet with Grape API? I'm using a standard config, but I'm not sure whether it actually is enabled for Grape API calls.
My config in development env file:
config.after_initialize do
Bullet.enable = true
Bullet.bullet_logger = true
end
and the described error is raised even when
Bullet.enable = false
I'm having the exact same issue
Is there a way to turn off bullet for Grape as a workaround?
What worked for me was setting
Bullet.enable = false
That way the error wasn't displayed anymore. But this is something that definitely needs to be fixed
I didn't use grape
, but bullet works for rails
204 response.
maybe you can hack lib/bullet/rack.rb
and see what's wrong.
I encounter this bug too and found how to reproduce this issue: In a Grape API endpoint, write a query with an n+1 issue to trigger Bullet check and return 204 status, and there it shows. Solve the n+1 query issue to bypass this bug Yes, this bug needs to be fixed but you can avoid it for now.