Skip to content

fix(ios): Don't crash on a null DSN in sentry.options.json - #6958

Merged
antonis merged 3 commits into
mainfrom
antonis/ios-native-init-followup-tests
Oct 28, 2026
Merged

antonis merged 3 commits into
mainfrom
antonis/ios-native-init-followup-tests

Conversation

@antonis

@antonis antonis commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Follow-up to #6956.

If an app starts the SDK natively and its sentry.options.json contains "dsn": null, iOS crashes at launch with -[NSNull length]: unrecognized selector (an uncaught NSInvalidArgumentException). createOptionsWithDictionary passes the raw dsn value into getURLFromDSN:, and [NSURL URLWithString:] throws on NSNull.

getURLFromDSN: now returns nil for anything that isn't a string. With #6956, the start is then skipped because there's no valid DSN, and JS can still initialize the native SDK later.

Also adds tests for the RNSentrySDK start paths that #6956 didn't cover:

  • "dsn": null in the options file: doesn't crash and doesn't start.
  • A valid options file where configureOptions sets an invalid DSN: doesn't start.
  • JS init starts the SDK after a skipped native start.

💡 Motivation and Context

Found while adding tests for #6956: the null-DSN test crashed the test runner. The crash was already on main before #6956 and isn't caused by it. Android already guards this case (RNSentryStart.java). The JS init path is unaffected because JS doesn't start the native SDK without a DSN.

💚 How did you test it?

Locally, iPhone 16 Pro simulator, Release configuration (same as CI):

  • testDoesNotStartWithNullDsnInOptionsFile crashed with -[NSNull length] before the fix and passes after it.
  • RNSentryStartFromFileTests, RNSentryStartTests, RNSentrySDKStartInvalidOptionsTests: 27 tests, all passed.
  • Full RNSentryCocoaTester suite: 204 tests, 0 failures.
  • yarn lint:clang and yarn lint:swift pass.

📝 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

🤖 Generated with Claude Code

antonis and others added 2 commits October 28, 2026 12:11
An options file with `"dsn": null` passed NSNull into getURLFromDSN:,
which threw an NSInvalidArgumentException at launch. Android already
guards this case.

Also adds tests for the RNSentrySDK start paths: null DSN in the
options file, an invalid DSN set in configureOptions, and starting from
JS after a skipped native start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(ios): Don't crash on a null DSN in sentry.options.json by antonis and claude in #6958
  • fix(ios): Start native SDK without options file by trollixx in #6956
  • build(node): Bump Node to 22.23.4 by geoffg-sentry with sentry-junior in #6954
  • fix(tracing): Support Expo Router 58 in expoRouterIntegration by alwx in #6923
  • fix(android): Persist hard-crash envelopes to disk before the process exits by alwx in #6937
  • feat(tracing): Track WebView trace-propagation feature adoption by antonis and claude in #6938
  • build(deps): Bump body-parser to 2.4.0 to resolve DoS advisory by antonis and claude in #6948
  • fix(android): Apply screenshot masking options to error and feedback screenshots by antonis and claude in #6930
  • chore(deps): update Android SDK to v8.62.0 by github-actions in #6932
  • chore(deps): update Maestro to v2.12.0 by github-actions in #6945
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.35.0 to 3.0.0 by dependabot in #6944
  • chore(deps): bump the codeql-action group with 3 updates by dependabot in #6940
  • chore(deps): bump actions/upload-artifact from 7.0.1 to 7.0.2 by dependabot in #6941
  • chore(deps): bump fast-uri from 3.1.8 to 3.1.9 by antonis and claude with dependabot in #6946
  • chore(deps): bump undici from 6.29.0 to 6.29.1 by dependabot in #6947
  • chore(deps): bump actions/setup-node from 7.0.0 to 7.1.0 by dependabot in #6943
  • chore(deps): bump ruby/setup-ruby from 1.327.0 to 1.334.0 by dependabot in #6942
  • chore(deps): bump ip-address from 10.7.2 to 10.7.4 by dependabot in #6939
  • chore(deps): update Wizard to v9.0.0 by github-actions in #6936
  • chore(deps): update CLI to v3.8.2 by github-actions in #6933
  • ci: Move CI off end-of-life Node versions to Node 22 by antonis and claude in #6927

🤖 This preview updates automatically when you update the PR.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Oct 28, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 66207b7. Configure here.

@sentry

sentry Bot commented Oct 28, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.32.0 (112) Release

⚙️ sentry-react-native Build Distribution Settings

@antonis
antonis marked this pull request as ready for review October 28, 2026 11:51
@antonis
antonis requested review from a team and lucas-zimerman as code owners October 28, 2026 11:51

@alwx alwx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@antonis
antonis merged commit 1502cde into main Oct 28, 2026
100 of 104 checks passed
@antonis
antonis deleted the antonis/ios-native-init-followup-tests branch October 28, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants