pbrisbin / bugsnag-haskell

Bugsnag error reporter for Haskell
10 stars 7 forks source link

Headers are serialized to an array, and #60

Closed MaxGabriel closed 4 years ago

MaxGabriel commented 4 years ago

I noticed recently that the request (created from updateEventFromWaiRequest) is {} in our Bugsnag:

image

After some debugging, I think what is happening is that request headers are being serialized as an array, whereas Bugsnag expects an object. In the API docs here, the example has headers as an empty object {} (and that's also how it is in the screenshot). But if you use ghci to print the JSON:

toJSON $ BugsnagRequest Nothing (Just [("foo", "bar")]) Nothing Nothing Nothing
Object (fromList [("headers",Array [Array [String "foo",String "bar"]])])

So, I think this should be a fairly easy fix. I think possible options are:

  1. Manually write the toJSON instance for BugsnagRequest.
  2. Change the type of brHeaders to something else with a different FromJSON instance. This is a breaking change, but a possible upside is it could help remove the need for the orphan ToJSON instances for Bytestring and CI
pbrisbin commented 4 years ago

Wow, nice catch. I think I like (2).