frontapp icon indicating copy to clipboard operation
frontapp copied to clipboard

Receive Message Error Handling + 502 Consistency

Open stephenhyde opened this issue 2 years ago • 0 comments

I know this is probably a product of the API as 502 probably means something flapping at the ingress but regardless the library spits out a weird exception as there is no error handling on status codes (Or there is and it assumes JSON) and it tries to decode an HTML response as JSON.

Version: 0.0.11 Rails: 6.1.7.3 Ruby: 2.7.7

Error Snippet:

[809: unexpected token at '<html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> </body> </html> '](REDACTED?queue=failed#)

Stack Trace

/usr/local/bundle/gems/json-2.5.1/lib/json/common.rb:216:in `parse'
/usr/local/bundle/gems/json-2.5.1/lib/json/common.rb:216:in `parse'
/usr/local/bundle/gems/frontapp-0.0.11/lib/frontapp/client.rb:103:in `create'
/usr/local/bundle/gems/frontapp-0.0.11/lib/frontapp/client/messages.rb:126:in `receive_custom_message

Request:

FrontClient.client.receive_custom_message(channel, {
                                                  sender:
                                                    {
                                                      name: 'REDACTED',
                                                      handle: 'REDACTED'
                                                    },
                                                  subject: 'REDACTED,
                                                  body: 'REDACTED
                                                })

I can go ahead and wrap a standard error around this but I figure I throw it your way for visibility on 502 and the potential for status unwrapping in code.

stephenhyde avatar Sep 27 '23 01:09 stephenhyde