Skip to content

Fix: Trim Unicode NULL character for Windows support #420

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

Merged
merged 5 commits into from
Apr 20, 2021

Conversation

ueman
Copy link
Collaborator

@ueman ueman commented Apr 19, 2021

📜 Description

I replace every \u0000 with `` (empty string).

💡 Motivation and Context

#410

💚 How did you test it?

I've written new tests

📝 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

@bruno-garcia Could you please test this?

@ueman ueman marked this pull request as ready for review April 19, 2021 07:43
@@ -397,6 +409,7 @@ class LoadReleaseIntegration extends Integration<SentryFlutterOptions> {
.replaceAll('\t', '_')
.replaceAll('\r\n', '_')
.replaceAll('\r', '_')
.replaceAll('\n', '_');
.replaceAll('\n', '_')
.replaceAll('\u{0000}', '');
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to be sure that this works on Windows, maybe @bruno-garcia can test it?

Copy link
Member

Choose a reason for hiding this comment

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

I dream of integration test on the target platform that will validate these for us. Mainly because of regressions introduced later.

Thoughts? Q2 is the time to plan and book these tasks

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

name = _cleanString(packageInfo.appName);
}

final version = _cleanString(packageInfo.version);
Copy link
Member

Choose a reason for hiding this comment

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

This block is guarded by either release or dist being empty on options. But below we only take the release built in here, if options.release is not empty, we just use that, and same for dist.

So if only options.release is set, we'll build a new release (as per this block) but won't use it at all.
Would it make sense to check if + exists and append the buildNumber we detected in that case?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the ?? does the job if I got what you meant eg

options.release = options.release ?? release;

but what we could do is to actually check if we need to build the release or dist only and not execute code that is not necessary, eg, building a new release if we're going to use the options.release anyway as its not empty

Copy link
Member

Choose a reason for hiding this comment

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

yeah it's already using options.release if it's already set, it's just odd that we build a new release value even though it's not used.

And I was trying to think of ways to combine what we built in the block with what was defined but best not mess around with a value that was explicitly set by the user on options.

So the only improvement here is as you said just to avoid doing the work if not needed though it'll make the logic more complicated

options.logger(SentryLevel.debug, 'release: $release');

options.release = options.release ?? release;
options.dist = options.dist ?? packageInfo.buildNumber;
if (buildNumber.isNotEmpty) {
options.dist = options.dist ?? packageInfo.buildNumber;
Copy link
Member

Choose a reason for hiding this comment

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

We might need check the format of build number. Will this always be in a valid format as per Sentry's spec?
https://docs.sentry.io/platforms/dart/configuration/releases/#bind-the-version

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See #422

@marandaneto
Copy link
Contributor

The fix works! :)

image

https://sentry.io/organizations/sentry-sdks/issues/2137135923/?query=is%3Aunresolved

Screenshot 2021-04-19 at 22 11 22

If I opened the right JSON, sentry_flutter_example\[email protected] its still wrong, could you double check @bruno-garcia ?

@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2021

Codecov Report

Merging #420 (3c53608) into feature/support-desktop (a874f04) will increase coverage by 3.50%.
The diff coverage is n/a.

Impacted file tree graph

@@                     Coverage Diff                     @@
##           feature/support-desktop     #420      +/-   ##
===========================================================
+ Coverage                    90.02%   93.52%   +3.50%     
===========================================================
  Files                           54        5      -49     
  Lines                         1684      170    -1514     
===========================================================
- Hits                          1516      159    -1357     
+ Misses                         168       11     -157     
Impacted Files Coverage Δ
dart/lib/src/scope.dart
dart/lib/src/protocol/sentry_event.dart
dart/lib/src/protocol/sentry_stack_trace.dart
dart/lib/src/protocol/debug_image.dart
dart/lib/src/hub.dart
dart/lib/src/integration.dart
dart/lib/src/transport/http_transport.dart
dart/lib/src/platform/_io_platform.dart
dart/lib/src/protocol/sdk_version.dart
dart/lib/src/environment_variables.dart
... and 39 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a874f04...3c53608. Read the comment docs.

@bruno-garcia
Copy link
Member

oof, you're right @marandaneto

  "release": "sentry_flutter_example\u0000@1.0.0",

@bruno-garcia
Copy link
Member

There's no general 'error processing your event' on the event though. Wasn't that the case before this change?

@marandaneto
Copy link
Contributor

There's no general 'error processing your event' on the event though. Wasn't that the case before this change?

before it was sentry_flutter_example\[email protected]\u0000+

@ueman
Copy link
Collaborator Author

ueman commented Apr 19, 2021

There's no general 'error processing your event' on the event though. Wasn't that the case before this change?

I think that's because options.dist does not get set to an empty string anymore.

.getIntegration(loader: loader)
.call(MockHub(), fixture.options);

expect(fixture.options.release, 'sentry_flutter_example+123');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is wrong, in this case, if there's no version, it should be sentry_flutter_example@123

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll confirm that, let's keep as it is for now

Copy link
Contributor

@marandaneto marandaneto Apr 20, 2021

Choose a reason for hiding this comment

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

this is actually not going to happen because pubspec must have a version or it defaults to 0.0.0 https://dart.dev/tools/pub/pubspec#version
its only possible because we've mocked the values, so no special anything case here.

Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

LGTM

@ueman ueman merged commit 50ab07a into feature/support-desktop Apr 20, 2021
@ueman ueman deleted the fix/windows-invalid-chars branch April 20, 2021 08:15
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