Skip to content

feat(nav3): [Part 3] Record why back stack entries are /unknown - #6781

Merged
0xadam-brown merged 0 commit into
feat/nav3-serial-name-mappers-7from
feat/nav3-serial-name-stack-3
Nov 27, 2026
Merged

0xadam-brown merged 0 commit into
feat/nav3-serial-name-mappers-7from
feat/nav3-serial-name-stack-3

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Nov 25, 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

When Sentry can't name a back stack entry, it records the entry as /unknown. Until now, that's all it recorded. This PR records the reason next to the entry, under unknown_entry_reason:

Where Key
Back stack in the Navigation context unknown_entry_reason
Navigation breadcrumbs to_unknown_entry_reason, from_unknown_entry_reason
Navigation transaction data unknown_entry_reason

Breadcrumbs add the to_ and from_ prefixes their other keys use (to_arguments, from_arguments), as each describes two entries. Sentry stores these keys in alphabetical order, so the reason appears right after entry in the back stack, or after entry_arguments if the entry has arguments.

For example, a back stack whose top entry has a named companion object, minified by R8 with kotlinx.serialization 1.7.3:

"Back Stack": [
  { "entry": "/unknown", "unknown_entry_reason": "serializer_not_found" },
  { "entry": "/Home" }
]

The reasons are a fixed set and contain no app data or class names:

Reason Meaning
unmapped A custom mapper returned null
mapping_failed The mapper threw
blank_name The mapper returned a blank name (its arguments are kept)
not_serializable SerialName: the entry's class isn't @Serializable
generic_type SerialName: the entry's class has type parameters
serializer_not_found SerialName: no serializer was found, e.g., because R8 removed what the lookup needs
serializer_lookup_threw SerialName: reading the class's annotations, serializer, or descriptor threw
kotlinx_serialization_version SerialName couldn't be created, as the app's kotlinx.serialization version is incompatible

The transaction name stays /unknown, so unnamed screens don't add transaction names.

How SerialName reports its reason

map() returning null is public API, and apps build on it (SerialName.map(entry) ?: fallback), so SerialName still returns null. It reports the reason through an internal per-thread side channel that BackStackConverter clears and reads around each call to the app's mapper. As a result:

  • a custom mapper that forwards SerialName's null forwards its reason too;
  • a custom mapper that falls back to its own name records no reason, as the entry is named;
  • a custom mapper that returns null itself records unmapped.

Each type's reason is cached along with its failure, so it's looked up once. Generic @Serializable types are now detected before the serializer lookup, which can't find their serializers either, so they record generic_type and log a warning that says so.

💡 Motivation and Context

/unknown alone doesn't say what went wrong. "Not @Serializable", "R8 removed the serializer", "kotlinx.serialization is incompatible", and "the app's own mapper chose not to name it" all look the same. Many of the SerialName failures only happen in minified release builds, where nobody reads the SDK's debug logs. And all unnamed screens share one transaction name, so a broken setup can look like an app with few screens rather than a problem.

This records the reason where users already look, without changing the public map() contract.

addresses: JAVA-787 (link)

⚠️ Callouts

  • Behavior change: a mapper that throws now records "unknown_entry_reason": "mapping_failed" instead of "dropped_by_sentry": "mapping_failed" in the entry's arguments, so one cause has one name. mapping_failed shipped in 8.65.1 as an argument drop reason, so this changes a released value. The CHANGELOG says so.
  • Not added: a searchable nav.unknown_entry_reason transaction tag. That's a product question, and the tag is easy to add later.

💚 How did you test it?

  • Unit tests for the side channel (UnknownEntryReasonReportsTest), each reason through the converter, observer, and transaction request, and each SerialName reason (KotlinxBackStackEntryMapperUnknownEntryReasonTest)
  • SentryNavEffectTest end to end through Compose
  • Module tests at kotlinx.serialization 1.7.3 and 1.13.0

📝 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

  • Document the reasons in sentry-docs' Troubleshooting section.
  • Possibly detect systemic failures (most @Serializable types fail and none succeed) and log one summary warning.

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

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: not classified

For commit fb33ea0.

The last run ended with status pr_not_open, so this pull request has no risk label.

@github-actions

github-actions Bot commented Nov 25, 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 cfbf6ca

@sentry

sentry Bot commented Nov 25, 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-stack-3 branch from c3bbd3c to cfbf6ca Compare November 25, 2026 16:31
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 25, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-stack-3 branch from cfbf6ca to fb33ea0 Compare November 27, 2026 15:16
@0xadam-brown
0xadam-brown merged commit fb33ea0 into feat/nav3-serial-name-mappers-7 Nov 27, 2026
@0xadam-brown
0xadam-brown force-pushed the feat/nav3-serial-name-mappers-7 branch from 6937bd5 to c8bea42 Compare November 27, 2026 15:16
@0xadam-brown
0xadam-brown deleted the feat/nav3-serial-name-stack-3 branch November 27, 2026 15:16
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Nov 27, 2026
@0xadam-brown
0xadam-brown restored the feat/nav3-serial-name-stack-3 branch November 27, 2026 15:26
@0xadam-brown

Copy link
Copy Markdown
Member Author

Replaced by #6801. Reordering the stack (this change now comes before the SerialName mapper) made GitHub mark this PR as merged, though nothing was merged. The discussion here still applies.

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.

1 participant