errbit/errbit — Issue #139: Wrong association of error to application
Author: gorenje
Created: 2011-12-16 07:56:33+00:00
State: open

I've got 2 application (each with their own app id) but they represent the production and staging instances of the same application. This means they raise the same exceptions (based on the fingerprint of the exception).

What I just discovered was that when i raised a specific exception on the production machine (new exception), it got associated with the production application. When i then raise the same exception on the staging machine, it also got associated with the production application even though the app_id (sent with the exception report) was of the staging instance.

I had a quick look through the code and i think it's: https://github.com/errbit/errbit/blob/master/app/models/app.rb#L83-85 which does not take the application id into account when searching for existing errors (the part before the '||').

The find_or_create_err!(attrs) method get called by ErrorReport with the following (https://github.com/errbit/errbit/blob/master/app/models/error_report.rb#L40-45):

err = app.find_or_create_err!(
:klass => klass,
:component => component,
:action => action,
:environment => rails_env,
:fingerprint => fingerprint)

i.e. also no app id. So there is nothing limiting the search for existing errors to the current application.

Since i can repeat this quite easily, i'm going to have a look at fixing it by adding an extra where(...) to the find_or_create_err! method.