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

Add fallback metadata in the event of report file corruption #327

Merged
merged 2 commits into from
Feb 21, 2019

Conversation

kattrali
Copy link
Contributor

Goal

Capture and report basic report metadata in the event that a crash report file is corrupted or otherwise could not be written.

Design

The file path calculation logic is altered to include the severity, handled-ness, and first few characters of the error class, which are parsed and used in the event that the file cannot be read.

This change refactors the sendReports/filterReports parameter types to include the file path, which required some alteration to the Sink and ApiClient callback type signatures since an array was no longer being passed around (and we only used the count of the array anyhow).

Tests

  • Tested manually on iOS and Apple TV
  • Added new automated tests for the file path calculation logic and scenario where the file is corrupted

@kattrali kattrali changed the title Kattrali/low disk space optim Add fallback metadata in the event of report file corruption Feb 19, 2019
@kattrali kattrali force-pushed the kattrali/low-disk-space-optim branch from d272aed to 6911165 Compare February 19, 2019 15:23
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

Didn't have time to do a comprehensive review, but I've left a few comments about what I managed to go through so far. Mostly this looks like a good approach! I wasn't able to run anything locally due to time constraints.

CHANGELOG.md Show resolved Hide resolved
features/crashprobe.feature Show resolved Hide resolved
Source/BugsnagApiClient.h Show resolved Hide resolved


if ([self isIncomplete]) {
BSGDictSetSafeObject(event, @YES, BSGKeyIncomplete);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to include the field if it's false also? This would allow filtering on the value either way

@@ -620,6 +645,42 @@ - (NSString *_Nullable)enhancedErrorMessageForThread:(NSDictionary *_Nullable)th

@end

@implementation FallbackReportData

- (instancetype)initWithMetadata:(NSString *)metadata {
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to separate this out into individual methods to improve readability (e.g. one that returns the severity, another that returns the handled state, etc).

Tests/BSGFilepathTests.m Show resolved Hide resolved
Source/BugsnagFileStore.m Show resolved Hide resolved
@snmaynard snmaynard requested a review from CodeHex February 19, 2019 19:36
@kattrali kattrali force-pushed the kattrali/low-disk-space-optim branch from 6911165 to e849ff2 Compare February 20, 2019 10:20
This change formats report file names to include minimal metadata:

* Add accessor for report contents indexed by filename
* Add async-safe customized filepath generator
* Update the callbacks to explicitly include the report count

Incomplete reports have been corrupted or otherwise could not be
written, and thus have no content in the report data dictionary.

Fallback values are parsed from the file name metadata and used as
needed without depending on an individual value to determine
"incomplete-ness".
@kattrali kattrali force-pushed the kattrali/low-disk-space-optim branch from e849ff2 to fdb769b Compare February 20, 2019 11:28
The change to filenames means that both crashes can now be reported
since they will use different paths and avoid overwriting the other.
Copy link

@CodeHex CodeHex left a comment

Choose a reason for hiding this comment

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

Looking through the changes, it seems OK to me but I'm not very familiar with codebase. Tried this locally by forcing the reports to be incomplete in various ways with various exceptions. Verified that the incomplete flag is set properly in the pipeline. LGTM once the tests pass

@kattrali kattrali merged commit 200e89b into master Feb 21, 2019
@kattrali kattrali deleted the kattrali/low-disk-space-optim branch February 21, 2019 12:27
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