bugsnag-ruby icon indicating copy to clipboard operation
bugsnag-ruby copied to clipboard

Breadcrumb Mongo query succeeded meta_data collection:Array has been dropped for having an invalid data type

Open godfrey-altmetric opened this issue 5 years ago • 2 comments

Describe the bug

The error: DEBUG -- [Bugsnag]: Breadcrumb Mongo query succeeded meta_data collection:Array has been dropped for having an invalid data type

Bugsnag is failing to create the breadcrumbs when rescuing Mongoid::Errors::Validations. We recently upgraded to Rails v5.2.4.4 and immediately started seeing these errors in our logs when a failed attempt to persist a record is rescued: gems/mongoid-6.1.1/lib/mongoid/persistable.rb:76:in 'fail_due_to_validation!'

This is the code for the rescue:

        begin
          identifier_mapping.save! if identifier_mapping.changed?
        rescue Mongoid::Errors::Validations => e
          Bugsnag.notify(e)
          Rails.logger.warn(e.message)
        end

According to https://docs.bugsnag.com/platforms/ruby/rails/automatically-captured-data/ for Mongo breadcrumbs, you automatically capture the collection type meta_data for this breadcrumb type.

However, since the upgrade the Rails, these errors are being logged. We didn't change our Bugsnag version, and the Breadcrumbs validations doesn't seem to support the type Array, which leaves me wondering if the returned error from Mongoid has changed, and this needs to be added to the validations, as per this issue:https://github.com/bugsnag/bugsnag-ruby/issues/539

Environment

  • Bugsnag version: 6.15.0
  • Ruby version:
  • Bundle version: 2.1.4
  • Integration framework version:
    • Rails: 5.2.4.4
    • Mongoid: 6.1.1
    • Mongo: 2.10.2

godfrey-altmetric avatar Oct 01 '20 10:10 godfrey-altmetric

Hi @godfrey-altmetric

Thanks for reporting. We're taking a look.

mattdyoung avatar Oct 07 '20 23:10 mattdyoung

Hey @godfrey-altmetric, I've been looking into this today but I can't reproduce this issue. Is there anything in your application that might be affecting this? For example, do you change the Mongoid collection with methods like Model.with(collection: 'xyz')?

Mongoid didn't support Rails 5.1 until v6.2.0, so it's possible this is a compatibility issue and updating Mongoid may resolve it

The validation we do is actually no longer necessary, so I've removed it in https://github.com/bugsnag/bugsnag-ruby/pull/648 which should be in the next release. This should stop the logs you're seeing and might help debugging the issue as we'll be able to see what collection is

imjoehaines avatar Dec 22 '20 15:12 imjoehaines