Skip to content

refactor: [SDK-5059] require an explicit attribution verdict on CrashData - #35

Merged
abdulraqeeb33 merged 4 commits into
mainfrom
ar/sdk-5059-attribution-contract
Nov 17, 2026
Merged

abdulraqeeb33 merged 4 commits into
mainfrom
ar/sdk-5059-attribution-contract

Conversation

@abdulraqeeb33

@abdulraqeeb33 abdulraqeeb33 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #34. Two changes to the attribution contract that came out of reviewing the Android host side.

CrashData.attributed loses its default. 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:

swift_name("init(threadName:exceptionType:exceptionMessage:stacktrace:attributed:)")

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. LogCrashReporter now logs attributed alongside 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.attributed is also named on both ILogCrashReporter methods, which previously documented only ossdk.crash.fatal, so a host implementer reading that interface could not learn the second tag exists.

The CrashData KDoc 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

attributed exists 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 CrashData constructor, 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: CrashData is public in a published artifact, so an external consumer would be broken by the constructor, copy, and componentN signature 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 NoSuchMethodError in its crash handler. Bumping com.onesignal:kmp past 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:testDebugUnitTest and :kmp:iosSimulatorArm64Test are green at 250 and 252 tests, 0 failures, with spotlessCheck clean. 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 20d8b88 actually 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 both ossdk.crash.attributed and ossdk.crash.fatal. The assertion carries a payload lower bound so a gutted record cannot satisfy it trivially.

Checklist

  • I reviewed my changes.
  • I added or updated tests, or explained why they are not needed.
  • I confirmed there are no unintended public API changes.

Made with Cursor

AR Abdul Azeez and others added 2 commits November 17, 2026 14:08
…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>
@abdulraqeeb33
abdulraqeeb33 requested a review from a team as a code owner November 17, 2026 20:12
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 fadi-george 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.

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>
@abdulraqeeb33

Copy link
Copy Markdown
Contributor Author

Both in b82d82e and the description.

  1. KDoc now says why there is no default.
  2. Added a release note: no 4-arg JVM constructor since feat: [SDK-5059] tag crash records with whether attribution succeeded #34, so hosts need a rebuild rather than a dependency bump. No changelog in this repo, so it sits in the PR body.

@abdulraqeeb33
abdulraqeeb33 merged commit 7444e69 into main Nov 17, 2026
2 checks passed
@abdulraqeeb33
abdulraqeeb33 deleted the ar/sdk-5059-attribution-contract branch November 17, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants