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

Fix: SentryEvent.throwable returns the unwrapped throwable instead of the throwableMechanism #311

Merged
merged 5 commits into from
Feb 23, 2021

Conversation

marandaneto
Copy link
Contributor

@marandaneto marandaneto commented Feb 22, 2021

📜 Description

Fix: SentryEvent.throwable returns the unwrapped throwable instead of the throwableMechanism

💡 Motivation and Context

#304

💚 How did you test it?

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

@marandaneto marandaneto requested a review from a team February 22, 2021 18:31
Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marandaneto not possible to take the same approach as we did in Java and on the getter unwrap our throwable?

having two fields to get a throwable isn't ideal

@marandaneto
Copy link
Contributor Author

docs getsentry/sentry-docs#3138

@marandaneto
Copy link
Contributor Author

@marandaneto not possible to take the same approach as we did in Java and on the getter unwrap our throwable?

having two fields to get a throwable isn't ideal

I did exactly the same approach :) our internal SDK needs access to the mechanism but clients would need the unwrapped version, that's why 2 getters

@bruno-garcia
Copy link
Member

@marandaneto not possible to take the same approach as we did in Java and on the getter unwrap our throwable?
having two fields to get a throwable isn't ideal

I did exactly the same approach :) our internal SDK needs access to the mechanism but clients would need the unwrapped version, that's why 2 getters

Shouldn't we reconsider this?
For our internal API we can use an internal API instead of adding two APIs one of which is useless to users?

@marandaneto
Copy link
Contributor Author

marandaneto commented Feb 22, 2021

we'd break literally every beforeSend and that was the reason adding the originThrowable at that time, why would we change now?

it's gonna be public anyway because of being used by another packages

@bruno-garcia
Copy link
Member

bruno-garcia commented Feb 22, 2021

we'd break literally every beforeSend and that was the reason adding the originThrowable at that time, why would we change now?

it's gonna be public anyway because of being used by another packages

What would break, I don't follow?
We should no longer returns our wrapping throwable, but return the original one.

For the internal API we can have another getter (package internal) that we can use to get the wrapper exception

How would we even document:

getThrowable - the throwable (maybe wrapped by some Sentry throwable so we can add more data)
originThrowable - The throwable that was captured (maybe the same as getThorwable, sometimes)

Please use only originThrowable.

@marandaneto
Copy link
Contributor Author

we'd break literally every beforeSend and that was the reason adding the originThrowable at that time, why would we change now?
it's gonna be public anyway because of being used by another packages

What would break, I don't follow?
We should no longer returns our wrapping throwable, but return the original one.

For the internal API we can have another getter (package internal) that we can use to get the wrapper exception

How would we even document:

getThrowable - the throwable (maybe wrapped by some Sentry throwable so we can add more data)
originThrowable - The throwable that was captured (maybe the same as getThorwable, sometimes)

Please use only originThrowable.

getsentry/sentry-java#1201
during stand up we'll have agreed to use getOriginThrowable, the points you've mentioned right now were already on the table before, we just avoided a breaking change.

@bruno-garcia
Copy link
Member

Not sure it's worth increasing the public API surface in the expense of potential more confusion just to avoid a breaking change without at least putting some thought into it.

Could we please consider simply returning the unwrapped Throwable and having an internal API instead for the internal behavior? Should we be using hints like the other SDKs to add the mechanism information instead? Maybe we should do things differently here altogether, I added this mechanism stuff back on Java 1.7, there might be a better way to go about this now.

We can bump a major if that's needed.

Regarding the name: why 'originThrowable"? Is it the "original throwable"?

What about "sourceThrowable" I'm not sure any of these names are much better given we already have getThrowable().

@marandaneto marandaneto changed the title Fix: Expose SentryEvent.originThrowable to get access to the origin Throwable Fix: SentryEvent.throwable returns the unwrapped throwable instead of the throwableMechanism Feb 23, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@marandaneto
Copy link
Contributor Author

Not sure it's worth increasing the public API surface in the expense of potential more confusion just to avoid a breaking change without at least putting some thought into it.

Could we please consider simply returning the unwrapped Throwable and having an internal API instead for the internal behavior? Should we be using hints like the other SDKs to add the mechanism information instead? Maybe we should do things differently here altogether, I added this mechanism stuff back on Java 1.7, there might be a better way to go about this now.

We can bump a major if that's needed.

Regarding the name: why 'originThrowable"? Is it the "original throwable"?

What about "sourceThrowable" I'm not sure any of these names are much better given we already have getThrowable().

let's keep the discussion in a single PR, right now it's spread across a few others.
I've changed this PR to unwrap the Throwable for Event.throwable and added a Event.throwableMechanism that returns the wrapped ThrowableMechanism, as this was not released yet, it was in time to fix it, on Java, we can discuss later as it'd be a breaking change.

@codecov-io
Copy link

Codecov Report

Merging #311 (1320bf7) into main (e8fbf20) will increase coverage by 0.75%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #311      +/-   ##
==========================================
+ Coverage   86.63%   87.39%   +0.75%     
==========================================
  Files          52       47       -5     
  Lines        1751     1531     -220     
==========================================
- Hits         1517     1338     -179     
+ Misses        234      193      -41     
Impacted Files Coverage Δ
dart/lib/src/protocol/sentry_event.dart 94.89% <75.00%> (-1.85%) ⬇️
dart/lib/src/sentry_client.dart 90.90% <100.00%> (ø)
.../lib/src/navigation/sentry_navigator_observer.dart
flutter/lib/src/sentry_flutter_options.dart
flutter/lib/src/widgets_binding_observer.dart
flutter/lib/src/sentry_flutter.dart
flutter/lib/src/file_system_transport.dart

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e8fbf20...25face6. Read the comment docs.

@marandaneto marandaneto requested review from ueman and a team February 23, 2021 08:27
@marandaneto
Copy link
Contributor Author

marandaneto commented Feb 23, 2021

@bruno-garcia
Copy link
Member

btw looks like JS use hints for this docs.sentry.io/platforms/javascript/configuration/filtering/#using-hints similar to forum.sentry.io/t/capture-sentry-error/12811

Yes on other SDKs is all about hints.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM

@marandaneto marandaneto merged commit 4cab306 into main Feb 23, 2021
@marandaneto marandaneto deleted the fix/origin-throwable branch February 23, 2021 19:46
@ueman ueman mentioned this pull request Feb 24, 2021
7 tasks
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.

4 participants