Association Associate error

Feature(s) impacted

I have a many-to-many relationship between two models, Coupon and Offer, I put a before_add callback on my association in Coupon to raise an error to indicate you cannot associate Coupon and Offer if Coupon is a marketplace kind

Observed behavior

An error is raised but the message is “update failed: unexpected error.”

Expected behavior

I specify in my method a message and I would like to display it in the notification window

Failure Logs

Started POST "/forest/Coupon/131/relationships/offers?timezone=Europe%2FParis" for 127.0.0.1 at 2024-01-31 15:10:16 +0100
Processing by ForestLiana::AssociationsController#associate as JSON
  Parameters: {"data"=>[{"id"=>"3", "type"=>"offer"}], "timezone"=>"Europe/Paris", "collection"=>"Coupon", "id"=>"131", "association_name"=>"offers"}
  Coupon Load (1.2ms)  SELECT "coupons".* FROM "coupons" WHERE "coupons"."id" = $1 LIMIT $2  [["id", 131], ["LIMIT", 1]]
  ↳ lib/forest_liana/controllers/associations_controller.rb:50:in `associate'
  CACHE Coupon Load (0.0ms)  SELECT "coupons".* FROM "coupons" WHERE "coupons"."id" = $1 LIMIT $2  [["id", 131], ["LIMIT", 1]]
  ↳ lib/forest_liana/controllers/associations_controller.rb:50:in `associate'
  Offer Load (0.5ms)  SELECT "offers".* FROM "offers" WHERE "offers"."id" = $1 LIMIT $2  [["id", 3], ["LIMIT", 1]]
  ↳ lib/forest_liana/controllers/associations_controller.rb:50:in `associate'
DEPRECATION WARNING: Time#to_s(:db) is deprecated. Please use Time#to_fs(:db) instead. (called from associate at /Users/loicboussiquet/MVMS/APIs/api-stats/lib/forest_liana/controllers/associations_controller.rb:50)
[2024-01-31 15:10:16] Forest 🌳🌳🌳  Association Associate error: Impossible de sauvegarder: Kind Le type de coupon ne peut pas être marketplace
/Users/loicboussiquet/MVMS/APIs/api-stats/app/models/coupon.rb:73:in `check_type'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/builder/collection_association.rb:47:in `block (2 levels) in define_callback'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:481:in `block in callback'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:480:in `each'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:480:in `callback'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:450:in `block in replace_on_target'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:449:in `catch'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:449:in `replace_on_target'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:272:in `add_to_target'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:430:in `block in concat_records'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:428:in `each'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:428:in `concat_records'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/has_many_association.rb:130:in `concat_records'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/has_many_through_association.rb:40:in `concat_records'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:125:in `block in concat'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/transactions.rb:209:in `transaction'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:308:in `transaction'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_association.rb:125:in `concat'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/has_many_through_association.rb:21:in `concat'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/associations/collection_proxy.rb:1032:in `<<'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/forest_liana-8.0.12/app/services/forest_liana/has_many_associator.rb:16:in `block in perform'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/forest_liana-8.0.12/app/services/forest_liana/has_many_associator.rb:15:in `each'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/forest_liana-8.0.12/app/services/forest_liana/has_many_associator.rb:15:in `perform'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/forest_liana-8.0.12/app/controllers/forest_liana/associations_controller.rb:63:in `associate'
        /Users/loicboussiquet/MVMS/APIs/api-stats/lib/forest_liana/controllers/associations_controller.rb:50:in `associate'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/abstract_controller/base.rb:215:in `process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_controller/metal/rendering.rb:53:in `process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/abstract_controller/callbacks.rb:234:in `block in process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actiontext-7.0.3.1/lib/action_text/rendering.rb:20:in `with_renderer'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actiontext-7.0.3.1/lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/callbacks.rb:127:in `instance_exec'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/callbacks.rb:138:in `run_callbacks'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/abstract_controller/callbacks.rb:233:in `process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/notifications.rb:206:in `block in instrument'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/notifications.rb:206:in `instrument'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_controller/metal/instrumentation.rb:66:in `process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/abstract_controller/base.rb:151:in `process'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionview-7.0.3.1/lib/action_view/rendering.rb:39:in `process'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_controller/metal.rb:188:in `dispatch'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_controller/metal.rb:251:in `dispatch'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/routing/route_set.rb:32:in `serve'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/journey/router.rb:50:in `block in serve'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/journey/router.rb:32:in `each'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/journey/router.rb:32:in `serve'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/routing/route_set.rb:852:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-cors-2.0.1/lib/rack/cors.rb:102:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/stack.rb:61:in `block in call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/notifications.rb:206:in `block in instrument'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/notifications.rb:206:in `instrument'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/stack.rb:60:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/engine.rb:530:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/railtie.rb:226:in `public_send'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/railtie.rb:226:in `method_missing'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/routing/mapper.rb:48:in `serve'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/journey/router.rb:50:in `block in serve'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/journey/router.rb:32:in `each'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/journey/router.rb:32:in `serve'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/routing/route_set.rb:852:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/flipper-1.0.0/lib/flipper/middleware/memoizer.rb:72:in `memoized_call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/flipper-1.0.0/lib/flipper/middleware/memoizer.rb:37:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/rack/browser_monitoring.rb:38:in `traced_call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:266:in `context'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:260:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/cookies.rb:697:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/warden-1.2.9/lib/warden/manager.rb:36:in `block in call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in `catch'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/tempfile_reaper.rb:15:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/etag.rb:27:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/conditional_get.rb:40:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/head.rb:12:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/http/permissions_policy.rb:38:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/http/content_security_policy.rb:36:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:266:in `context'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:260:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/cookies.rb:697:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:603:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/callbacks.rb:99:in `run_callbacks'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/show_exceptions.rb:26:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/rack/logger.rb:40:in `call_app'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/rack/logger.rb:25:in `block in call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/tagged_logging.rb:114:in `block in tagged'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/tagged_logging.rb:38:in `tagged'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/tagged_logging.rb:114:in `tagged'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/rack/logger.rb:25:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/request_id.rb:26:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/method_override.rb:24:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/runtime.rb:22:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/server_timing.rb:20:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/static.rb:23:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.7/lib/rack/sendfile.rb:110:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/actionpack-7.0.3.1/lib/action_dispatch/middleware/host_authorization.rb:137:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rack-cors-2.0.1/lib/rack/cors.rb:102:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/engine.rb:530:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/puma-5.6.6/lib/puma/configuration.rb:252:in `call'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/puma-5.6.6/lib/puma/request.rb:77:in `block in handle_request'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/puma-5.6.6/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/puma-5.6.6/lib/puma/request.rb:76:in `handle_request'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/puma-5.6.6/lib/puma/server.rb:443:in `process_client'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/puma-5.6.6/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/tracer.rb:434:in `block (2 levels) in thread_block_with_current_transaction'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/tracer.rb:356:in `capture_segment_error'
        /Users/loicboussiquet/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/newrelic_rpm-9.3.1/lib/new_relic/agent/tracer.rb:433:in `block in thread_block_with_current_transaction'
Completed 500 Internal Server Error in 14ms (ActiveRecord: 1.7ms | Allocations: 3466)```

Context

  • Project name: MVMS API-Stats
  • Team name: Operations
  • Environment name: Development(Local)
  • Agent (forest package) name & version: forest-liana 8.0.12
  • Database type: postgresql
  • Recent changes made on your end if any: …
class Coupon < ApplicationRecord
     has_and_belongs_to_many :offers, before_add: :check_type

    def check_type(_offer)
        return if b2b_subcriptions? || b2b_offers?
        errors.add(:kind, :equal_to)
        raise ActiveRecord::RecordInvalid.new(self)
    end
end

Hello @Loic_Boussiquet

Unfortunately you can’t set a personalised message into the notification window.
I push this feature to our productbard

Kind regards

Hello !

Thank you for your answer

Kind regards