Skip to content
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

Truncate Exception Messages if needed #646

Merged
merged 3 commits into from
Dec 21, 2020
Merged

Conversation

imjoehaines
Copy link
Contributor

This is PR #636 rebased onto next + a changelog entry


Goal

If an exception occurs, such as a Mysql2::Error::ConnectionError, where the query is extremely long, this can cause the payload to exceed what Bugsnag will accept and throw a Errno::EPIPE: Broken pipe error when trying to send the request to Bugsnag.

A number of elements are already trimmed when the payload is too large, including meta data, stacktrace code, etc. However, the exception messages were not being trimmed.

This commit adds exception message trimming to Bugsnag::Helpers.trim_if_needed, which should help reduce errors when the queries causing the errors are exceptionally long.

Design

A number of elements are already trimmed when the payload is too large, including meta data, stacktrace code, etc. However, the exception messages were not being trimmed.

This commit adds exception message trimming to Bugsnag::Helpers.trim_if_needed, which should help reduce errors when the queries causing the errors are exceptionally long.

Changeset

Added truncate_exception_messages to Bugsnag::Helpers.trim_if_needed method, which truncates the exception messages if necessary.

Testing

Manually on our Rails 4.2 / Bugsnag 6.17.0 enterprise application.

Added a spec to helper_spec.rb that tests this functionality specifically.

✅ All tests passing when running bundle exec rake.

joshuapinter and others added 2 commits December 21, 2020 09:49
If an exception occurs, such as a `Mysql2::Error::ConnectionError`, where the query is extremely long, this can cause the payload to exceed what Bugsnag will accept and throw a `Errno::EPIPE: Broken pipe` error when trying to send the request to Bugsnag.

A number of elements are already trimmed when the payload is too large, including meta data, stacktrace code, etc. However, the exception messages were not being trimmed.

This commit adds exception message trimming to `Bugsnag::Helpers.trim_if_needed`, which should help reduce errors when the queries causing the errors are exceptionally long.

It also adds a spec to `helper_spec.rb` that tests this functionality.
Base automatically changed from fix-delayed-job-tests to next December 21, 2020 14:25
@imjoehaines imjoehaines marked this pull request as ready for review December 21, 2020 14:26
spec/helper_spec.rb Outdated Show resolved Hide resolved
@imjoehaines imjoehaines merged commit 3169dff into next Dec 21, 2020
@imjoehaines imjoehaines deleted the truncate_exception_messages branch December 21, 2020 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants