If a custom object responds to id
method, show the id and class value, instead of showing "[OBJECT]" in error reports
#605
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is PR #531 rebased onto
next
Goal
When bugsnag prints out the arguments passed to a job, if the arguments are custom objects (like a Struct, or an ActiveRecord object), Bugsnag only prints out "[OBJECT]" in its place, instead of providing any details, like
While bugsnag does this for the right reason (we should not show details of the whole object using
inspect
, because of PII), for developers who have not written ato_s
in the model, just seeing"[OBJECT]"
in place of the actual object details becomes a nightmare. Such errors become practically impossible to debug because, well, you do not know which object caused the issue.This PR is aimed at solving this problem to some extent, ie, at least in case of ActiveRecord objects.
Design
All ActiveRecord objects have an
id
method on it by default. If the custom object does not respond toto_s
and we cannot show it on bugsnag due to data-sensitivity issue, we can still show theid
of the object.Reasons:
email
oraddress
(which could be exposed if we give out the whole value ofinspect
on an object)Result
Bugsnag will now show arguments as
Changeset
Added
Added condition to check if the object responds to
id
method. If so, theid
of the object is being returned as the value of the argument.Removed
Changed
Tests
Added tests to assert that for custom objects that respond to the
id
method, theid
of the object is returned as the value of the object, rather than the string"[OBJECT]"
Discussion
Alternative Approaches
Outstanding Questions
Linked issues
Review
For the submitter, initial self-review:
For the pull request reviewer(s), this changeset has been reviewed for: