Skip to content

ref(nav3): [Part 1] Share bounded argument conversion - #6702

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

0xadam-brown wants to merge 1 commit into
feat/nav3-serial-name-mappers-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 Serial Name Mappers)

Former parts 1–3 merged into main as #6697, #6698, and #6699; preparatory refactors merged in #6749. Two other former parts merged separately as #6713 and #6714.


📜 Description

PR introduces the ArgumentSource <> ArgumentSink pair that lets us support differentiated processing on the source side (the host app's logic vs built-in mapper logic) but uniform processing on the sink side (argument pruning, protecting against constraint violation, and argument tree materialization). Absent that pair, we'd have to duplicate the latter for our built-in mappers, causing them to processing the argument tree twice.

💡 Motivation and Context

With Nav3, host apps manage their own nav back stack, which they implement as a list of arbitrarily typed entries. In order to be displayed in Sentry, each of those entries has to be mapped to a Sentry name (e.g., ProductDetailScreen) and zero or more arguments (e.g., productId). There are two ways for host apps to provide us with those mappings:

  1. via a custom BackStackEntryMapper; or
  2. via one of the own built-in mappers introduced by this PR stack (viz., BackStackEntryMapper.SerialName or BackStackEntryMapper.SerialNameAndProperties).

As mentioned above, the new ArgumentSource and ArgumentSink types let custom and built-in mappers apply different processing procedures, while sending the outputs of both through the shared sink pipeline. (Later PRs will take advantage of the source's ability to apply different processing policies).

Here are the moving parts:

                    ArgumentSource
       Custom mapper              Built-in mappers
  ┌────────────────────┐        ┌───────────────────────┐
  │ HostArgumentSource │        │ KotlinxArgumentSource │
  │  (plain host map)  │        │   (drives encoder)    │
  └────────┬───────────┘        └────────┬──────────────┘
           │                             │ via
           │        KotlinxPropertiesEncoder + SensitiveKeyFilter
           │                             │
           └──────────────┬──────────────┘
                          ▼
          ┌───────────────────────────────┐
          │         ArgumentSink          │
          └───────────────────────────────┘
                          ▲  sole impl
          ┌───────────────┴───────────────┐
          │      TreeArgumentWriter       │
          │                               │           ┌────────────────┐
          │   Enforce + materialize:      │ spends ──▶│ ArgumentBudget │
          │   • builds the argument tree  │           └────────────────┘
          │   • prevents constraint       │           ┌────────────────┐
          │      violation (e.g., cycles) │ throws ──▶│ DropArguments  │
          └───────────────────────────────┘           └────────────────┘

  Note: BackStackConverter.ArgumentSanitizer owns the ArgumentBudget and
  selects the ArgumentSource based on what the host app provides.

addresses: JAVA-787 (link)

💚 How did you test it?

Nav3 release build and unit tests passed. Repository-wide make format api, Spotless checks, ABI validation, and Detekt passed.

📝 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: Add the built-in SerialName 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 20, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit c5cc387.

Main concerns: data sent to Sentry, host performance, reach.

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
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-6 branch from d03d53a to b5f3e56 Compare November 23, 2026 13:11
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Nov 23, 2026
@0xadam-brown 0xadam-brown changed the title ref(nav3): [Part 6] Share bounded argument conversion ref(nav3): [Part 4] Share bounded argument conversion Nov 23, 2026
@0xadam-brown
0xadam-brown changed the base branch from feat/nav3-serial-name-mappers-5 to feat/nav3-serial-name-mappers-3 November 23, 2026 13:11
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 23, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-3 branch from 00922da to dda2831 Compare November 23, 2026 14:28
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-6 branch from b5f3e56 to 1d6fccd Compare November 23, 2026 14:28
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 23, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-6 branch from 1d6fccd to fcdfd79 Compare November 23, 2026 15:34
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-3 branch from dda2831 to a119f33 Compare November 23, 2026 15:34
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 23, 2026
Base automatically changed from feat/nav3-serial-name-mappers-3 to main November 24, 2026 06:56
@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
Comment on lines +202 to 209
private fun drop(drop: DropArguments): SanitizedArguments {
if (drop.reason.exhaustsUpdateBudget) {
dropReason = drop.reason
}
}

private fun exit(container: Any) {
activeContainers.remove(container)
}

/**
* Control-flow signal to abort sanitization of the current subtree. Internal to
* [ArgumentSanitizer].
*
* [reason] distinguishes entry-local drops from update-wide budget exhaustion. Overrides
* [fillInStackTrace] to skip stack-trace capture.
*/
private class DropSubtree(val warning: String, val reason: ArgumentDropReason) :
RuntimeException() {
override fun fillInStackTrace(): Throwable = this
}

companion object {

const val MAX_CHARACTER_WARNING =
"Nav3 back stack update exceeded the argument character limit. Dropping arguments for " +
"this and older entries."

const val MAX_COUNT_WARNING =
"Nav3 back stack update exceeded the argument value limit. Dropping arguments for this " +
"and older entries."

const val STRUCTURE_WARNING =
"Nav3 argument sanitization failed (possibly cyclic or too deeply nested). Dropping this " +
"entry's arguments."
drop.warning?.let { logger.log(WARNING, it) }
return SanitizedArguments(emptyMap(), drop.reason)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Catch parameter drop shadows the handler and fails compilation

In sanitizeEntry, the DropArguments catch parameter shadows the drop handler, so drop(sink.failure ?: drop) attempts to invoke the exception value and prevents the module from compiling. Rename the catch parameter or qualify the handler call.

Evidence
  • BackStackConverter.convert() reaches ArgumentSanitizer.sanitizeEntry() for mapped arguments.
  • In sanitizeEntry(), the catch parameter named drop is in scope at the call drop(sink.failure ?: drop).
  • The handler is a separate member function, private fun drop(drop: DropArguments), and DropArguments has no invoke operator; the catch call therefore fails compilation.

Identified by Warden · code-review · L53-F55

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