Skip to content

Commit ea4c613

Browse files
antonisclaude
andcommitted
fix(android): Fix crash when dsn or devServerUrl are missing from options
Fixes a crash on Android startup when initializing from sentry.options.json without dsn or devServerUrl fields. The code was calling getString() on ReadableMap without checking if the keys exist first, which throws NoSuchKeyException for missing keys. Both fields are optional in configuration files, so the code now checks for key existence before accessing values, returning null when keys are missing. This matches the pattern used throughout the rest of the file and is already handled correctly by the null-checks in the breadcrumb filter logic. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 8aa1902 commit ea4c613

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/core/android/src/main/java/io/sentry/react/RNSentryStart.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ static void getSentryAndroidOptions(
167167
configureAndroidProfiling(options, rnOptions, logger);
168168

169169
// Exclude Dev Server and Sentry Dsn request from Breadcrumbs
170-
String dsn = getURLFromDSN(rnOptions.getString("dsn"));
171-
String devServerUrl = rnOptions.getString("devServerUrl");
170+
String dsn = rnOptions.hasKey("dsn") ? getURLFromDSN(rnOptions.getString("dsn")) : null;
171+
String devServerUrl =
172+
rnOptions.hasKey("devServerUrl") ? rnOptions.getString("devServerUrl") : null;
172173
options.setBeforeBreadcrumb(
173174
(breadcrumb, hint) -> {
174175
Object urlObject = breadcrumb.getData("url");

0 commit comments

Comments
 (0)