fix(core): Trim DSN whitespace before native initialization#6081
fix(core): Trim DSN whitespace before native initialization#6081
Conversation
A stray space in the DSN string can cause a null pointer dereference in the native Cocoa/Android SDK during initialization. This trims whitespace and warns the user before passing the DSN to native code. Closes #6029 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0d6b485. Configure here.
alwx
left a comment
There was a problem hiding this comment.
Should we actually fix that? I mean it seems more like a configuration issue made by customer, not an issue on our side.
Good point @alwx 👍 The main issue is that the extra whitespace passes the core validation (and works for the most part) but causes the native side to crash as with the specific report. |
|
Regarding the bot feedback about whitespace-only DSNs (e.g. After trimming, a whitespace-only DSN becomes |
Ensures a whitespace-only DSN gets trimmed to empty string and is caught by the existing !options.dsn guard. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Probably it's fine for now — was just thinking that the fix is a bit redundant. But doesn't hurt much, I guess. |

📢 Type of change
📜 Description
Trims leading/trailing whitespace from the DSN before passing it to the native SDK during initialization. If whitespace is detected, a warning is logged to inform the user.
💡 Motivation and Context
A user reported a crash (
EXC_BAD_ACCESSinSentrySDKInternal.startWithOptions) caused by a stray space in their DSN string (#6029). The whitespace caused a null pointer dereference in the native Cocoa SDK during initialization.See #6029 (comment)
💚 How did you test it?
'test'to a valid DSN format (VALID_DSNconstant)📝 Checklist
sendDefaultPIIis enabled🔮 Next steps
#skip-changelog is this is a minor change