-
-
Notifications
You must be signed in to change notification settings - Fork 356
fix: Sanitize UserInfo of NSError and NSException #770
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #770 +/- ##
==========================================
- Coverage 92.83% 92.83% -0.01%
==========================================
Files 73 73
Lines 3212 3211 -1
==========================================
- Hits 2982 2981 -1
Misses 230 230
Continue to review full report at Codecov.
|
@koenpunt Thanks for contributing! |
As I mentioned in the description; I'm not really sure where I should add a test. |
Thanks for opening up this PR. You can add a test in You could add something like this below
But you need to add |
@philipphofmann thanks, I'll try that! |
@philipphofmann I used an |
The build is failing due to the branch name(?):
|
Without sanitizing the user info, `NSURLError`s would cause the sdk and context to be stripped from the event, because the user info of that error contains NSURL object.
Codecov Report
@@ Coverage Diff @@
## master #770 +/- ##
==========================================
- Coverage 92.83% 92.83% -0.01%
==========================================
Files 73 73
Lines 3212 3211 -1
==========================================
- Hits 2982 2981 -1
Misses 230 230
Continue to review full report at Codecov.
|
Oh I get it, it tried to commit formatting changes. Now ran clang-format locally and updated the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome thanks. The entry in the changelog is in the wrong section, but never worry I'm going to fix it in another PR :).
📜 Description
This PR add sanatizing to the error's user info dictionary.
💡 Motivation and Context
Certain errors would cause the event to drop the sdk and context properties, because the error's user info contained values that couldn't be serialized as JSON.
💚 How did you test it?
Changed the library in my project locally, and saw the error being reported in Sentry without the "A value set to the context or sdk is not serializable. Dropping context and sdk." breadcrumb, and with the context and sdk properties present.
I'm not sure where I should introduce a test for it. Preferably I would like to add a test that handles an error with problematic user info, and fails without my changes. But since the formatting of the event happens in SentryClient (covered by SentryClientTests), and the serialization in
SentrySerialization
(covered bySentrySerializationTests
), there currently is no way to do that.📝 Checklist
🔮 Next steps