Repository navigation
refactor: [SDK-5059] require an explicit attribution verdict on CrashData - #35
Merged
Merged
Conversation
…Data The `= true` default only ever applied to Kotlin callers. Swift never saw it, because Kotlin default parameters produce no Obj-C overload and the generated header exposes a single initializer that already requires `attributed`. So the default silently covered exactly the host where the gap is: Android's uncaught handler short-circuits `isOneSignalAtFault` for ANR-shaped throwables and would have reported them as proven. Dropping it turns that into a compile error when the submodule pointer moves, rather than a wrong value on the wire. Co-authored-by: Cursor <cursoragent@cursor.com>
…nterface Review follow-ups: - Log attributed alongside the label in LogCrashReporter. This is the only place both platforms share, so without it an iOS record's verdict cannot be reconstructed from logs at all. - Name ossdk.crash.attributed on both ILogCrashReporter methods; a host implementer reading that interface could not learn the tag exists. - Trim the CrashData KDoc back to the instruction a future reader needs. The design rationale belongs in the commit that made the change. Co-authored-by: Cursor <cursoragent@cursor.com>
A real crash record is mostly stacktrace, so it is the one the WAF body-cap trim actually shortens. Bool attributes are fitted before string ones and are dropped rather than truncated when they do not fit, so the flag surviving that path was reasoned about but never measured. Measured here: a ~265 KB crash still emits ossdk.crash.attributed and ossdk.crash.fatal. The payload lower bound keeps the assertion honest, since a gutted record would satisfy the flags trivially. Co-authored-by: Cursor <cursoragent@cursor.com>
fadi-george
approved these changes
Nov 17, 2026
fadi-george
left a comment
Contributor
There was a problem hiding this comment.
Potential issues:
- Non-blocking: release notes, Kotlin callers on v0.6.0 need a source change and a rebuild. #34 already dropped the 4-arg constructor, so a host that only bumps the dependency would hit NoSuchMethodError in the crash handler.
- Nit: CrashData.kt:12, "No default, on purpose." could say why in half a sentence, e.g. a default of true would mark every forgotten call site as attributed.
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Both in
|
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.
Summary
Follow-up to #34. Two changes to the attribution contract that came out of reviewing the Android host side.
CrashData.attributedloses its default. The= truedefault only ever applied to Kotlin callers. Swift never saw it, because Kotlin default parameters produce no Obj-C overload and the generated header exposes a single initializer that already requiresattributed:So the default silently covered exactly the host where the gap was. Android's uncaught handler short-circuited its fault check for ANR-shaped throwables and reported them as proven; see OneSignal/OneSignal-Android-SDK#2849. Dropping the default turns that class of mistake into a compile error instead of a wrong value on the wire.
The verdict becomes visible.
LogCrashReporternow logsattributedalongside the label. That is the only place both platforms share, so without it an iOS record's verdict cannot be reconstructed from logs at all.ossdk.crash.attributedis also named on bothILogCrashReportermethods, which previously documented onlyossdk.crash.fatal, so a host implementer reading that interface could not learn the second tag exists.The
CrashDataKDoc is trimmed back to the one instruction a future reader needs, which is not to add the default back. The reasoning lives in the commit.Motivation
attributedexists so the backend can separate crashes proven to be ours from ones a platform captured because it could not tell. A default that quietly answers "proven" for any caller who forgets defeats that, and it does so invisibly, since nothing fails and the record looks normal on the wire.Compatibility
Source-breaking for Kotlin callers of the
CrashDataconstructor, which is the point. Searched the org: the only constructors are this module's own tests, the Android host, and the iOS host. iOS already passes the argument explicitly at both sites, so it is unaffected. Android passes it explicitly too, so neither host needs the default.Worth a reviewer opinion:
CrashDatais public in a published artifact, so an external consumer would be broken by the constructor,copy, andcomponentNsignature change. I believe this type is not supported externally, but that is a call rather than something I can prove.One limit worth naming: the compile-time guarantee covers construction only.
crash.copy(...)still lets a caller omit the verdict and inherit whatever the source record said.Release note
This is binary-incompatible for Kotlin hosts. Default parameters do not generate a 4-arg JVM constructor, so #34 already removed it; a host that swaps the artifact without recompiling hits
NoSuchMethodErrorin its crash handler. Bumpingcom.onesignal:kmppast v0.6.0 requires a source change and a rebuild, not just a dependency bump. Worth calling out in the release notes since there is no changelog in this repo.Testing
:kmp:testDebugUnitTestand:kmp:iosSimulatorArm64Testare green at 250 and 252 tests, 0 failures, withspotlessCheckclean. The six test constructions now state a verdict explicitly.One test added beyond the contract change, prompted by review. A real crash record is mostly stacktrace, so it is the one the WAF body-cap trim from
20d8b88actually shortens, and bool attributes are fitted before strings but dropped rather than truncated when they do not fit. That the flag survives trimming had been reasoned about, not measured. It is measured now: a ~265 KB crash still emits bothossdk.crash.attributedandossdk.crash.fatal. The assertion carries a payload lower bound so a gutted record cannot satisfy it trivially.Checklist
Made with Cursor