bullet icon indicating copy to clipboard operation
bullet copied to clipboard

Bullet raises the error on a Grape API endpoint with status: :no_content (204)

Open manme opened this issue 4 years ago • 7 comments

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

manme avatar Jun 26 '20 12:06 manme

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.

magneland avatar Jun 27 '20 02:06 magneland

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 

manme avatar Jun 28 '20 22:06 manme

I'm having the exact same issue

davidauza-engineer avatar May 25 '22 14:05 davidauza-engineer

Is there a way to turn off bullet for Grape as a workaround?

davidauza-engineer avatar May 25 '22 14:05 davidauza-engineer

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

davidauza-engineer avatar May 25 '22 14:05 davidauza-engineer

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.

flyerhzm avatar May 31 '22 12:05 flyerhzm

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.

iansrc0811 avatar Aug 21 '23 10:08 iansrc0811