Wednesday, July 31, 2013

Aibrake , Rack , Session_off ...

After installing Airbrake gem my collection's request Rspec.specs stoped working as expected.

I encounterd this error:

RuntimeError: can't add a new key into hash during iteration
Since Ruby 1.9(.3?) you cant modify Hash within iteration. ( even if they are ordered )

After some hours spent in debugger, I found that Airbrake gem Notification class uses Rack's Request @env variable to collect params for Aibrake/Errbit notification. Nothing weird here, but while collecting params in a loop , the clean_params method hit the racks request's @env with the #cookies method, in order to obtain the cookie hash. Code below :

Loading ....
I think that this is what misslead ThoughtBot guys, this method is available form the class Api ( I mean not private ) and returns the cookie Hash, but it also have side effects ... Sadly , it mutates the @env. I can't say if this is bad design or not, but it looks weird to mee.

In order to get this working I submitted a fix to Airbrake, not to Rack ...
Last words, thanks to ThoughBot guys, for all the opensource tools they provide, and reactivity to merge contribs.

Tuesday, July 30, 2013

Airbrake gem fails when your rails sessions are disabled

If you experiment
undefined method `data' for nil:NilClass
after installing Airbrake gem and you have disabled your rails sessions ( for example with the session_off gem ) This is because airbrake read the session.data property to send them to the server. Since you disabled Session's , your controller's session returns nil. I submitted a fix to airbrake, if you can't wait you can source your aibrake gem from my github repository Edit : My branch has been merged in master, you can now rely on master.

Le réveil



Rien n'est plus confus ... d'ou je viens ? Qui suis-je ? Que suis-je?
Ils ont tous une explication, aucune n'est satisfaisante. On m'a donné un nom, que ce soit réellement le mien ou pas je n'ai plus qu'a faire avec.
On ne peut pas en changer, ça fait partie des règles.
"Tu es des nôtres ..."