fix(replay): Guard against non-dictionary touch breadcrumb path elements#6346
Merged
Conversation
Fixes a fatal NSInvalidArgumentException (-[__NSCFString objectForKey:]: unrecognized selector) in RNSentryReplayBreadcrumbConverter when a touch breadcrumb path contains a non-dictionary element. - getTouchPathMessageFrom: now validates each element with isKindOfClass:[NSDictionary class] before calling objectForKey:. - convertTouch: now guards that `path` is an NSArray, matching convertMultiClick:. Closes #6342 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
antonis
commented
Jun 25, 2026
📲 Install BuildsAndroid
|
Contributor
iOS (legacy) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d038a14+dirty | 3845.71 ms | 1228.11 ms | -2617.59 ms |
| 41d6254+dirty | 3845.71 ms | 1224.51 ms | -2621.20 ms |
| 4966363+dirty | 3854.04 ms | 1231.55 ms | -2622.50 ms |
| c004dae+dirty | 3850.32 ms | 1227.79 ms | -2622.53 ms |
| eb93136+dirty | 3843.09 ms | 1220.11 ms | -2622.98 ms |
| 71abba0+dirty | 3821.93 ms | 1202.81 ms | -2619.12 ms |
| ad66da3+dirty | 3820.96 ms | 1214.43 ms | -2606.52 ms |
| ca9d079+dirty | 3835.63 ms | 1218.68 ms | -2616.95 ms |
| df5d108+dirty | 1225.90 ms | 1220.14 ms | -5.76 ms |
| 4b87b12+dirty | 1212.90 ms | 1222.09 ms | 9.19 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d038a14+dirty | 5.15 MiB | 6.67 MiB | 1.51 MiB |
| 41d6254+dirty | 5.15 MiB | 6.70 MiB | 1.54 MiB |
| 4966363+dirty | 5.15 MiB | 6.68 MiB | 1.53 MiB |
| c004dae+dirty | 5.15 MiB | 6.67 MiB | 1.51 MiB |
| eb93136+dirty | 5.15 MiB | 6.69 MiB | 1.53 MiB |
| 71abba0+dirty | 5.15 MiB | 6.67 MiB | 1.52 MiB |
| ad66da3+dirty | 5.15 MiB | 6.67 MiB | 1.51 MiB |
| ca9d079+dirty | 5.15 MiB | 6.69 MiB | 1.53 MiB |
| df5d108+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
| 4b87b12+dirty | 3.38 MiB | 4.77 MiB | 1.39 MiB |
Contributor
iOS (new) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d038a14+dirty | 3831.11 ms | 1216.30 ms | -2614.81 ms |
| 41d6254+dirty | 3849.78 ms | 1233.91 ms | -2615.86 ms |
| 4966363+dirty | 3863.07 ms | 1227.19 ms | -2635.88 ms |
| c004dae+dirty | 3857.82 ms | 1224.87 ms | -2632.95 ms |
| eb93136+dirty | 3846.51 ms | 1226.13 ms | -2620.39 ms |
| 71abba0+dirty | 3852.70 ms | 1224.53 ms | -2628.16 ms |
| ad66da3+dirty | 3855.02 ms | 1213.43 ms | -2641.59 ms |
| ca9d079+dirty | 3818.62 ms | 1216.72 ms | -2601.90 ms |
| df5d108+dirty | 1207.34 ms | 1210.50 ms | 3.16 ms |
| 4b87b12+dirty | 1199.49 ms | 1199.78 ms | 0.29 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d038a14+dirty | 5.15 MiB | 6.67 MiB | 1.51 MiB |
| 41d6254+dirty | 5.15 MiB | 6.70 MiB | 1.54 MiB |
| 4966363+dirty | 5.15 MiB | 6.68 MiB | 1.53 MiB |
| c004dae+dirty | 5.15 MiB | 6.67 MiB | 1.51 MiB |
| eb93136+dirty | 5.15 MiB | 6.69 MiB | 1.53 MiB |
| 71abba0+dirty | 5.15 MiB | 6.67 MiB | 1.52 MiB |
| ad66da3+dirty | 5.15 MiB | 6.67 MiB | 1.51 MiB |
| ca9d079+dirty | 5.15 MiB | 6.69 MiB | 1.53 MiB |
| df5d108+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
| 4b87b12+dirty | 3.38 MiB | 4.77 MiB | 1.39 MiB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Fixes a fatal
NSInvalidArgumentExceptioncrash inRNSentryReplayBreadcrumbConverter(Session Replay on iOS):getTouchPathMessageFrom:iterated over a touch breadcrumb'spatharray and treated every element as anNSDictionary, only guarding againstnil. When an element was a non-dictionary (e.g. anNSString), callingobjectForKey:on it raisedNSInvalidArgumentException→SIGABRT.Two gaps are addressed:
getTouchPathMessageFrom:— each element is now validated withisKindOfClass:[NSDictionary class]before any dictionary access (the same pattern already used inconvertNavigation:).convertTouch:— now guards thatpathis anNSArraybefore use, matching the existingconvertMultiClick:implementation. Previously a non-arraypathwould crash on[path count](NSStringdoes not respond tocount).💡 Motivation and Context
Reported in #6342 — observed as a fatal crash in production on iOS with Session Replay enabled (RN 0.81.5, Expo SDK 54, New Architecture + Hermes). The malformed touch-path element bypassed all existing guards.
Closes #6342
💚 How did you test it?
Added unit tests to
RNSentryReplayBreadcrumbConverterTests.swiftthat reproduce the crash and assert it no longer occurs:testTouchMessageReturnsNilOnNonDictionaryPathElement— the exact reported case (a string element).testTouchMessageReturnsNilWhenAnyPathElementIsNotADictionary— non-dict element mixed with valid dicts.testConvertTouchBreadcrumbWithNonDictionaryPathElementDoesNotCrash— exercised end-to-end viaconvert(from:).testConvertTouchBreadcrumbWithNonArrayPathDoesNotCrash— non-arraypath.These crash on the previous code and pass with the fix. Ran clang-format on the modified ObjC file.
📝 Checklist
sendDefaultPiiis enabled.🔮 Next steps
None.