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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Scope.clone incorrectly accesses tags #978

Merged
merged 2 commits into from Aug 17, 2022

Conversation

quaaantumdev
Copy link
Contributor

@quaaantumdev quaaantumdev commented Aug 6, 2022

馃摐 Description

fixed Scope.clone, incorrectly accesses tags and therefore crashes. Main branch currently extracts the keys from _tags to iterate over. This is all fine but it the tries to access the values via the keys-list which makes no sense, it's a list of strings, not a map where you could actually use the keys. I guess it's simply a typo due to "not so optimal" naming.

馃挕 Motivation and Context

Sentry crashing, error reporting with tags does not work. The following code will crash (current main branch):

Sentry.configureScope((scope) async {
  await scope.setTag('some.tag', 'value');
});

await Sentry.captureException(
  error,
  stackTrace: stackTrace,
  hint: 'here goes an error',
  withScope: (scope) async {
    try {
      await scope.setTag('class', className);
    } catch (err, stack) {
      print('ERROR: failed to add class in sentry: $err\n$stack');
    }
  },
);

馃挌 How did you test it?

running in production just fine :) currently using it via a pubspec.yaml git reference:

 sentry: # also remove override when fixed
    git:
      url: https://github.com/quaaantumdev/sentry-dart.git
      path: dart

would like to upgrade back to the official version once fixed

馃摑 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

let's make sentry great again ;-)

#skip-changelog

Copy link
Collaborator

@brustolin brustolin left a comment

Choose a reason for hiding this comment

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

LGTM

@brustolin brustolin enabled auto-merge (squash) August 8, 2022 06:47
@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2022

Codecov Report

Merging #978 (0cc8cbe) into main (1998016) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #978   +/-   ##
=======================================
  Coverage   91.14%   91.14%           
=======================================
  Files           9        9           
  Lines         192      192           
=======================================
  Hits          175      175           
  Misses         17       17           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@marandaneto
Copy link
Contributor

@quaaantumdev thanks for the PR, can you explain which issue are you getting? what's the error?
Please elaborate on:

incorrectly accesses tags and therefore crashes

@brustolin
Copy link
Collaborator

By incorrectly accesses tags and therefore crashes he means the variable name.

Old code:

final tags = List.from(_tags.keys); //tags is a list of string
     for (final tag in tags) {
       final value = tags[tag]; //tags is not a dictionary, we should be reading from _tags passing the key
       if (value != null) {
         clone._setTagSync(tag, value);
       }
    }

@brustolin brustolin merged commit 2ada18f into getsentry:main Aug 17, 2022
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.

None yet

4 participants