-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveRecord::RecordNotUnique should be handled similarly to PG::UniqueViolation #833
Comments
Hi @patbenatar, we can definitely take a look. Do you have an example error message for |
We've monkey-patched like so in our app: module Appsignal
class Transaction
def cleaned_error_message(error)
case error.class.to_s
when "PG::UniqueViolation", "ActiveRecord::RecordNotUnique"
error.message.to_s.gsub(/\)=\(.*\)/, ")=(?)")
else
error.message.to_s
end
end
end
end Perhaps rather than adding a list of error classes here, we could make this method extensible via configuration? We use https://github.com/ankane/logstop elsewhere in our application and it'd be great to be able to configure Appsignal to use that too, something like: config.clean_error_message = ->(msg) { ... } |
Looks like you sent a
We considered that in the past, but decided not to add it to this first version. We want to take a good look at how best to fix this for all integrations, not just Ruby. |
It's wrapped. That's the error message for the AR exception. Sounds good re: configuration. Simply adding the AR exception class to the list as I've done in my monkey patch would be great for now. Thanks! |
Like we've done before for `PG::UniqueViolation`, sanitize the `ActiveRecord::RecordNotUnique` message. The `RecordNotUnique` error class is a type of error that wraps around errors from database adapter gems like the "pg" gem's `PG::UniqueViolation`. The message for this `RecordNotUnique` error is the same for `PG::UniqueViolation` in this case, prefixed with error class name. Fixes #833
I've submitted the fix in PR #834. |
@patbenatar The fix for this is released in Ruby gem 3.0.25. |
@tombruijn thank you! |
Rails wraps
PG::UniqueViolation
in aActiveRecord::RecordNotUnique
. Should this code https://github.com/appsignal/appsignal-ruby/blob/main/lib/appsignal/transaction.rb#L538 handle both?The text was updated successfully, but these errors were encountered: