-
Notifications
You must be signed in to change notification settings - Fork 130
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
Handle nil content value #289
Conversation
It appears that "value" can be nil in some situations, which could lead to an nsexception being raised on subsequent operations. this change skips the iteration if this is the case.
if ([self isReservedWord:contentValue]) { | ||
reservedWord = contentValue; | ||
} else if (!([[contentValue componentsSeparatedByString:@"/"] count] > 2)) { | ||
} else if ([[contentValue componentsSeparatedByString:@"/"] count] <= 2) { |
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.
This change just simplifies the condition to make it more readable
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.
The code change itself looks good to me.
It's not super obvious to me that there is a test case that covers the specific situation where contentValue
is nil. Should there be a test where the value for the key "value" is explicitly set as nil?
I've added both an implicit and explicit test case for where "value" can be nil. I've also added a type check as the original issue occurred if |
Source/BugsnagCrashReport.m
Outdated
@@ -630,9 +630,12 @@ + (instancetype)errorDataFromThreads:(NSArray *)threads { | |||
} | |||
NSString *contentValue = data[@"value"]; | |||
|
|||
if (!contentValue) { | |||
#pragma clang diagnostic push | |||
#pragma ide diagnostic ignored "OCDFAInspection" |
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.
suppresses warnings on a redundant nsstring type check, which actually isn't redundant when contentValue
is NSNull
Goal
The notifier currently assumes that the "value" key in notable_addresses data is non-null, whereas this is not necessarily the case, which can lead to an
NSInvalidArgumentException
.This change adds unit test coverage for this method, and ensures that it can handle any of the items in the dictionary being null.
Changeset
Added
Unit Tests which cover behaviour of the class.
Removed
Changed
Skip iteration if the contentValue is nil.
Review
For the submitter, initial self-review:
For the pull request reviewer(s), this changeset has been reviewed for: