Skip to content

fix(ios): Start native SDK without options file - #6956

Merged
antonis merged 1 commit into
getsentry:mainfrom
trollixx:fix/ios-native-init-missing-options
Oct 28, 2026
Merged

antonis merged 1 commit into
getsentry:mainfrom
trollixx:fix/ios-native-init-missing-options

Conversation

@trollixx

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

When sentry.options.json is missing or can't be parsed, RNSentrySDK falls back to optionsFromDictionary:@{ }. Cocoa reads the missing dsn key as an empty DSN and rejects it, so the fallback always returns nil and configureOptions never runs. Before 8.30.0 this crashed at launch; since #6825, the native SDK silently never starts.

This PR falls back to default SentryOptions instead, and skips the start only if neither the file nor configureOptions set a valid DSN, so JS can still initialize the native SDK later. The now-unreachable nil guard in RNSentrySDK.m is removed.

Behavior change: an options file with "dsn": null used to start a native SDK that couldn't send events. It now skips the start.

💡 Motivation and Context

An iOS app without sentry.options.json that sets the DSN in [RNSentrySDK startWithConfigureOptions:] never starts the native SDK. Android already handles this case.

Related: #6822, #6825.

💚 How did you test it?

The tests for this path (RNSentryStartFromFileTests.swift, RNSentryStartTests.swift) lost their project.pbxproj entries when #5582 landed and haven't run since. This PR registers them and their fixtures again, updates them for Cocoa 9, and adds regression tests for a DSN set in configureOptions with a missing or unparseable options file.

I haven't built or run the tester locally (no Mac), so I'm relying on CI.

📝 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. (N/A: no public API changes)
  • No breaking changes.

🔮 Next steps

@trollixx
trollixx requested review from a team and lucas-zimerman as code owners October 28, 2026 01:44
@trollixx
trollixx force-pushed the fix/ios-native-init-missing-options branch 2 times, most recently from e0e1077 to ac496f9 Compare October 28, 2026 01:46
RNSentrySDK fell back to parsing an empty dictionary when
sentry.options.json was missing or could not be parsed. Cocoa reads a
missing "dsn" key as an empty DSN and rejects it, so the fallback always
failed and configureOptions never ran. Before 8.30.0 this crashed at
launch; since then the native SDK silently never starts.

Fall back to default SentryOptions instead, and skip the start only
when neither the file nor configureOptions set a valid DSN, so that a
later init from JS can still start the native SDK.

Register RNSentryStartTests, RNSentryStartFromFileTests and their
fixtures in the Cocoa tester project again. They were lost when getsentry#5582
landed and have not run since. Update them for Cocoa 9 and add
regression tests for a DSN set in configureOptions.
@trollixx
trollixx force-pushed the fix/ios-native-init-missing-options branch from ac496f9 to 77924c6 Compare October 28, 2026 01:54
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Oct 28, 2026
@antonis
antonis self-requested a review October 28, 2026 09:08

@antonis antonis 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.

Thank you for your contribution @trollixx 🙇
LGTM 🚀

@antonis
antonis merged commit f78b6fd into getsentry:main Oct 28, 2026
125 of 137 checks passed
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