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

Fail gracefully when the provided json is not valid #4474

Open
wants to merge 4 commits into
base: antonis/ref-RNSentryJsonUtils
Choose a base branch
from

Conversation

antonis
Copy link
Collaborator

@antonis antonis commented Jan 21, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

Based on #4470

📜 Description

Fail gracefully when the provided json is not valid

⛓️ PR Chain

💡 Motivation and Context

See #4451 (comment)

💚 How did you test it?

CI, Manual

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

#skip-changelog

Copy link
Contributor

github-actions bot commented Jan 21, 2025

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 494.31 ms 480.49 ms -13.82 ms
Size 17.75 MiB 20.11 MiB 2.37 MiB

Baseline results on branch: antonis/ref-RNSentryJsonUtils

Startup times

Revision Plain With Sentry Diff
11c0bc5 419.08 ms 454.54 ms 35.46 ms
eff021d 428.13 ms 417.82 ms -10.31 ms
f9a2e3c 449.64 ms 469.63 ms 19.99 ms

App size

Revision Plain With Sentry Diff
11c0bc5 17.75 MiB 20.11 MiB 2.37 MiB
eff021d 17.75 MiB 20.11 MiB 2.37 MiB
f9a2e3c 17.75 MiB 20.11 MiB 2.37 MiB

Previous results on branch: antonis/rnsentrysdk-fails-gracefully

Startup times

Revision Plain With Sentry Diff
d69e49a 463.81 ms 447.30 ms -16.51 ms

App size

Revision Plain With Sentry Diff
d69e49a 17.75 MiB 20.11 MiB 2.37 MiB

Copy link
Contributor

github-actions bot commented Jan 21, 2025

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 427.62 ms 459.00 ms 31.38 ms
Size 7.15 MiB 8.38 MiB 1.23 MiB

Baseline results on branch: antonis/ref-RNSentryJsonUtils

Startup times

Revision Plain With Sentry Diff
f9a2e3c+dirty 386.92 ms 435.47 ms 48.55 ms
11c0bc5+dirty 393.98 ms 421.85 ms 27.87 ms
eff021d+dirty 404.96 ms 469.09 ms 64.13 ms

App size

Revision Plain With Sentry Diff
f9a2e3c+dirty 7.15 MiB 8.38 MiB 1.23 MiB
11c0bc5+dirty 7.15 MiB 8.38 MiB 1.23 MiB
eff021d+dirty 7.15 MiB 8.38 MiB 1.23 MiB

Previous results on branch: antonis/rnsentrysdk-fails-gracefully

Startup times

Revision Plain With Sentry Diff
d69e49a+dirty 369.38 ms 435.34 ms 65.96 ms

App size

Revision Plain With Sentry Diff
d69e49a+dirty 7.15 MiB 8.38 MiB 1.23 MiB

Copy link
Contributor

github-actions bot commented Jan 21, 2025

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1227.37 ms 1217.86 ms -9.51 ms
Size 2.63 MiB 3.69 MiB 1.05 MiB

Baseline results on branch: antonis/ref-RNSentryJsonUtils

Startup times

Revision Plain With Sentry Diff
11c0bc5+dirty 1215.18 ms 1217.63 ms 2.45 ms
eff021d+dirty 1233.80 ms 1221.47 ms -12.33 ms
f9a2e3c+dirty 1230.61 ms 1221.64 ms -8.97 ms

App size

Revision Plain With Sentry Diff
11c0bc5+dirty 2.63 MiB 3.69 MiB 1.05 MiB
eff021d+dirty 2.63 MiB 3.69 MiB 1.05 MiB
f9a2e3c+dirty 2.63 MiB 3.69 MiB 1.05 MiB

Previous results on branch: antonis/rnsentrysdk-fails-gracefully

Startup times

Revision Plain With Sentry Diff
d69e49a+dirty 1218.84 ms 1226.67 ms 7.84 ms

App size

Revision Plain With Sentry Diff
d69e49a+dirty 2.63 MiB 3.69 MiB 1.05 MiB

Copy link
Contributor

github-actions bot commented Jan 21, 2025

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1232.71 ms 1226.04 ms -6.67 ms
Size 3.19 MiB 4.25 MiB 1.06 MiB

Baseline results on branch: antonis/ref-RNSentryJsonUtils

Startup times

Revision Plain With Sentry Diff
11c0bc5+dirty 1242.98 ms 1250.56 ms 7.58 ms
eff021d+dirty 1228.45 ms 1220.27 ms -8.18 ms
f9a2e3c+dirty 1222.06 ms 1223.62 ms 1.56 ms

App size

Revision Plain With Sentry Diff
11c0bc5+dirty 3.19 MiB 4.25 MiB 1.06 MiB
eff021d+dirty 3.19 MiB 4.25 MiB 1.06 MiB
f9a2e3c+dirty 3.19 MiB 4.25 MiB 1.06 MiB

Previous results on branch: antonis/rnsentrysdk-fails-gracefully

Startup times

Revision Plain With Sentry Diff
d69e49a+dirty 1220.98 ms 1222.71 ms 1.73 ms

App size

Revision Plain With Sentry Diff
d69e49a+dirty 3.19 MiB 4.25 MiB 1.06 MiB

Comment on lines +39 to +43
logger.log(
SentryLevel.WARNING,
"Failed to load configuration file("
+ CONFIGURATION_FILE
+ "), starting with configuration callback.");
Copy link
Member

Choose a reason for hiding this comment

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

I think this log is not necessary/is duplicate as the same information will be logged out in getOptionsFromConfigurationFile.

mockedRNSentryStart.close()
mockedRNSentryJsonUtils.close()
}

Copy link
Member

Choose a reason for hiding this comment

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

Can you also add integration test which won't use the mocks (maybe just to supply the file) and initializes the SDK?

}

@Test
fun `fails with an error when there is an unhandled exception in initialisation`() {
Copy link
Member

Choose a reason for hiding this comment

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

This test is a bit confusing to me, as the getOptionsFromConfigurationFile should never throw.

*/
public static void init(
@NotNull final Context context,
@NotNull Sentry.OptionsConfiguration<SentryAndroidOptions> configuration) {
@NotNull Sentry.OptionsConfiguration<SentryAndroidOptions> configuration,
@NotNull ILogger logger) {
try {
JSONObject jsonObject =
RNSentryJsonUtils.getOptionsFromConfigurationFile(context, CONFIGURATION_FILE, logger);
ReadableMap rnOptions = RNSentryJsonUtils.jsonObjectToReadableMap(jsonObject);
Copy link
Member

Choose a reason for hiding this comment

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

I think the SDK won't initialize when the jsonObject.get throws. Can we add test for it and avoid the rethrow.

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.

2 participants