Skip to content

feat(nav3): [Part 2] Add an argument source for encoding back stack entry properties via kotlinx.serialization - #6751

Merged
0xadam-brown merged 3 commits into
feat/nav3-serial-name-mappers-basefrom
feat/nav3-serial-name-mappers-argument-source
Dec 4, 2026
Merged

0xadam-brown merged 3 commits into
feat/nav3-serial-name-mappers-basefrom
feat/nav3-serial-name-mappers-argument-source

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

PR Stack (Nav3 SerialNameAndProperties Mapper)

This stack follows the SerialName stack (#6780) and is based on its last PR, #6783.


📜 Description

PR adds KotlinxArgumentSource, the ArgumentSource (see Part 1) that the built-in SerialNameAndProperties mapper (Part 3) uses to turn a back stack entry's kotlinx.serialization properties into Sentry arguments.

ArgumentSanitizer now lets arguments that are an ArgumentSource write themselves, and a source can drop its arguments without a warning when it has already reported the failure itself.

Nothing uses the source yet; Part 3 wires it into SerialNameAndProperties. It was split out of that PR to keep it reviewable.

💡 Motivation and Context

Implements the ArgumentSource discussed in #6705 that we need in order to extract properties from the host app's back stack (via kotlinx.serialization).

addresses: JAVA-787 (link)

💚 How did you test it?

  • Unit tests
  • Manual tests via the Nav3 sample app
  • Clanker stress tests

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the 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.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Continue with Part 3: Add the built-in SerialNameAndProperties mapper.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

#skip-changelog

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 03c5a89

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 03c5a89.

Main concerns: data sent to Sentry, public contract, reach.

This label is a hint for reviewers, not an approval.

@sentry

sentry Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.65.1 (1) release

⚙️ sentry-android Build Distribution Settings

@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-argument-source branch from 849c9d0 to ef7030c Compare December 1, 2026 01:31
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-8 branch from f4a7b52 to d6095b5 Compare December 1, 2026 01:31
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 1, 2026
@0xadam-brown 0xadam-brown changed the title feat(nav3): [Part 4] Add a lazily encoding argument source for kotlinx properties feat(nav3): [Part 2] Add a lazily encoding argument source for kotlinx properties Dec 1, 2026
@0xadam-brown
0xadam-brown marked this pull request as ready for review December 1, 2026 01:49
@0xadam-brown
0xadam-brown requested review from a team and adinauer as code owners December 1, 2026 01:49
@0xadam-brown
0xadam-brown requested review from markushi and runningcode and removed request for a team December 1, 2026 01:49
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 1, 2026
@0xadam-brown 0xadam-brown changed the title feat(nav3): [Part 2] Add a lazily encoding argument source for kotlinx properties feat(nav3): [Part 2] Add an argument source for encoding back stack entry properties using kotlinx.serialization Dec 1, 2026
@0xadam-brown 0xadam-brown changed the title feat(nav3): [Part 2] Add an argument source for encoding back stack entry properties using kotlinx.serialization feat(nav3): [Part 2] Add an argument source for encoding back stack entry properties via kotlinx.serialization Dec 1, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-argument-source branch from ef7030c to 81bf950 Compare December 1, 2026 10:01
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-8 branch from d6095b5 to 7e35dad Compare December 1, 2026 10:01
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 1, 2026

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

LGTM! Just one comment below!

@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-argument-source branch from 81bf950 to cd976bc Compare December 4, 2026 10:17
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026
Base automatically changed from feat/nav3-serial-name-mappers-8 to feat/nav3-serial-name-mappers-base December 4, 2026 11:17
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026
0xadam-brown and others added 3 commits December 4, 2026 12:19
Add KotlinxArgumentSource, the arguments the SerialNameAndProperties
mapper will return. It encodes an entry's properties only when they're
read or written, so an entry whose arguments the update's budget has
already ruled out isn't encoded at all. Read as a map, it encodes once and
caches the result; written to the sanitizer's sink, it encodes against
the update's shared budget.

ArgumentSanitizer now lets arguments that are an ArgumentSource write
themselves, and a source can drop its arguments without a warning when it
has reported the failure itself. Add the encoding_failed drop reason for
entries whose properties can't be encoded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…esult

KotlinxArgumentSource checked the sink's recorded failure in each catch to decide which
failure dropped the arguments. Its cached copy now comes from TreeArgumentSink.write, which
makes that decision, and encode calls checkNotDropped() where a serializer may have replaced a
broken limit with its own exception. ArgumentSource becomes a fun interface so encode can be
passed to write directly.

Refs JAVA-787
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KotlinxArgumentSource encoded an entry's properties only when its arguments were read or
written. As a map, its equals and hashCode read its entries, so comparing two
SentryBackStackEntry values ran the app's serializers on the comparing thread, and could change
what Sentry later recorded.

Replace it with KotlinxArguments.encode, which encodes an entry once, into a budget of its own,
and returns a plain map. The sanitizer treats that map like any other mapper's, so it no longer
needs arguments that write themselves, and a dropped entry's reason is an ordinary argument.

Eager encoding runs every captured entry's serializers, including those of entries whose
arguments the update's budget will drop. Measured on a Pixel 4, that costs 30-60 us more per
navigation at the default of 5 captured entries, and grows with the number captured. Treat
maxCapturedBackStackEntries values above 25 as 25 to bound it.

Refs JAVA-787
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-argument-source branch from d737c2e to 03c5a89 Compare December 4, 2026 11:20
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026
@0xadam-brown 0xadam-brown added the sanity-check PR needs a lightweight review for obvious issues label Dec 4, 2026
@0xadam-brown
0xadam-brown merged commit 65aadcb into feat/nav3-serial-name-mappers-base Dec 4, 2026
39 of 42 checks passed
@0xadam-brown
0xadam-brown deleted the feat/nav3-serial-name-mappers-argument-source branch December 4, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants