Skip to content

ref(nav3): [Part 1] Gather nav data keys in one package and simplify ArgumentSanitizer - #6702

Open
0xadam-brown wants to merge 1 commit into
feat/nav3-serial-name-stack-basefrom
feat/nav3-serial-name-mappers-6
Open

0xadam-brown wants to merge 1 commit into
feat/nav3-serial-name-stack-basefrom
feat/nav3-serial-name-mappers-6

Conversation

@0xadam-brown

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

Copy link
Copy Markdown
Member

PR Stack (Nav3 SerialName Mapper)

This stack replaces the SerialName half of #6696. SerialNameAndProperties will follow in its own stack.


📜 Description

Groundwork for the rest of the stack. No behavior change.

One home for what the Sentry UI shows

The Nav3 integration writes the captured back stack into a Navigation context, from/to fields into breadcrumbs, and arguments into transaction data. Those keys, the /unknown name, and the argument drop reasons are what users see and search in Sentry, so changing one is a user-facing change.

They used to be private constants spread over the backstack and lifecycle packages. This PR moves them into one internal contract package, and adds a test that pins each displayed string. Part 2 adds unknown_entry_reason to the same place.

The lifecycle package may import only this package from the rest of the module. PackageBoundariesTest enforces that, and also that the contract package imports nothing else from the module.

A simpler argument sanitizer

A custom mapper may return arguments with each entry. ArgumentSanitizer bounds them before they're recorded:

  • Shared budgets: 200 values and 4,096 characters per back stack update, spent from the top of the back stack down, so the newest entries keep their arguments.
  • Per-entry limits: a nesting depth of 10, no cycles, and no two map keys that stringify the same way.

Arguments that break a rule are dropped and replaced by a dropped_by_sentry reason.

The rules are unchanged. The code now recurses directly instead of going through visit/enter/exit helpers, and checks a CharSequence's length before copying it. The sanitizer's tests now live together in ArgumentSanitizerTest.

💡 Motivation and Context

An earlier version of this PR added an ArgumentSource/ArgumentSink pipeline, so that the properties mapper could feed its encoder's output through the same limits. SerialName records no properties, so nothing in this stack needs it. It can come back with the SerialNameAndProperties stack, next to the encoder that uses it.

The contract package gives Part 2 and Part 3 one place to add the values they record. It also lets the mapper's kotlinx package avoid importing its parent package.

addresses: JAVA-787 (link)

💚 How did you test it?

  • NavDataContractTest pins every displayed key and value
  • ArgumentSanitizerTest covers each limit, drop reason, and supported value type
  • The module's existing tests pass unchanged apart from imports

📝 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 2: Record why back stack entries are /unknown.

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

#skip-changelog

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 328049c.

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

Rules that block low also fired:

  • R1: code was truncated, omitted or a reduced context was used: sentry-android-navigation3/src/test/kotlin/io/sentry/compose/navigation3/internal/backstack/ArgumentSanitizerTest.kt, sentry-android-navigation3/src/test/kotlin/io/sentry/compose/navigation3/internal/backstack/BackStackConverterTest.kt, sentry-android-navigation3/src/test/kotlin/io/sentry/compose/navigation3/internal/backstack/BackStackObserverTest.kt, sentry-android-navigation3/src/test/kotlin/io/sentry/compose/navigation3/internal/backstack/CoordinatedBackStackObserverTest.kt, sentry-android-navigation3/src/test/kotlin/io/sentry/compose/navigation3/internal/contract/NavDataContractTest.kt and 3 more

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

@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 20, 2026
@sentry

sentry Bot commented Nov 20, 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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d03d53a. Configure here.

@0xadam-brown 0xadam-brown added the sanity-check PR needs a lightweight review for obvious issues label Nov 20, 2026
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Nov 24, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-6 branch from fcdfd79 to c5cc387 Compare November 24, 2026 10:21
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 24, 2026
@0xadam-brown 0xadam-brown changed the title ref(nav3): [Part 4] Share bounded argument conversion ref(nav3): [Part 1] Share bounded argument conversion Nov 24, 2026
@0xadam-brown
0xadam-brown changed the base branch from main to feat/nav3-serial-name-mappers-base November 24, 2026 10:22
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 24, 2026
…gumentSanitizer

The keys and values the Sentry UI shows (context, breadcrumb, and
transaction keys, the /unknown name, and the argument drop reasons and
limits) now live in one internal contract package, which the lifecycle
package may import. A test pins each displayed string.

ArgumentSanitizer recurses directly instead of through visit/exit
helpers, checks a CharSequence's length before copying it, and has its
own test suite.
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-6 branch from 19c6402 to 328049c Compare November 27, 2026 15:16
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 27, 2026
@0xadam-brown 0xadam-brown changed the title ref(nav3): [Part 1] Share bounded argument conversion ref(nav3): [Part 1] Gather nav data keys in one package and simplify ArgumentSanitizer Nov 27, 2026
@0xadam-brown
0xadam-brown marked this pull request as ready for review November 27, 2026 17:23
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 27, 2026

This branch has not been deployed

No deployments
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.

1 participant