diff --git a/CHANGELOG.md b/CHANGELOG.md index 3556c3283a..39c2566442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- LoadImageListIntegration won't throw bad state if there is no exceptions in the event ([#1347](https://github.com/getsentry/sentry-dart/pull/1347)) + ## 7.1.0 ### Features diff --git a/flutter/lib/src/integrations/load_image_list_integration.dart b/flutter/lib/src/integrations/load_image_list_integration.dart index 4757d6be00..967385cd5f 100644 --- a/flutter/lib/src/integrations/load_image_list_integration.dart +++ b/flutter/lib/src/integrations/load_image_list_integration.dart @@ -22,9 +22,16 @@ class LoadImageListIntegration extends Integration { extension _NeedsSymbolication on SentryEvent { bool needsSymbolication() { - if (this is SentryTransaction) return false; + if (this is SentryTransaction) { + return false; + } + if (exceptions?.isNotEmpty == false) { + return false; + } final frames = exceptions?.first.stackTrace?.frames; - if (frames == null) return false; + if (frames == null) { + return false; + } return frames.any((frame) => 'native' == frame.platform); } } diff --git a/flutter/test/integrations/load_image_list_test.dart b/flutter/test/integrations/load_image_list_test.dart index f3aaa09776..1dd4ab1839 100644 --- a/flutter/test/integrations/load_image_list_test.dart +++ b/flutter/test/integrations/load_image_list_test.dart @@ -154,6 +154,26 @@ void main() { expect('e77c5713-5311-28c2-ecf0-eb73fc39f450', image.debugId); expect('test', image.debugFile); }); + + test('Native layer is not called as there is no exceptions', + () async { + var called = false; + + final sut = fixture.getSut(); + fixture.channel + .setMockMethodCallHandler((MethodCall methodCall) async { + called = true; + return imageList; + }); + + sut.call(fixture.hub, fixture.options); + + expect(fixture.options.eventProcessors.length, 1); + + await fixture.hub.captureMessage('error'); + + expect(called, false); + }); }); } });