Fixed
Status Update
Comments
cl...@google.com <cl...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 4cf96f31d0cb929e120a5f4f531093e70ff0f61e
Author: Clara Fok <clarafok@google.com>
Date: Fri Aug 30 14:40:35 2024
Fix startDestination missing required arguments
When navigating to a NavGraph, after parsing the arguments (if any) from startDestination, we check to see if there are any missing required arguments (arguments that are non-nullable and do not have a default value).
Besides adding new tests, some existing tests have been refactored in either of the following 2 ways:
1. tests that tests for and allows startDestinations with misisng required args are now refactored to expect a missing arg exception
2. tests for behaviors unrelated to startDestination but has a startDestination with missing args is refactored to provide the required starting args
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 362594265
Relnote: "The route passed to a NavGraph's startDestination must contain the values for all required arguments, which are arguments that are non-nullable and don't have a default value."
Change-Id: I18e7401ac7a4d322db2add9b0f2781196d4d3257
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphNavigator.kt
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavGraphBuilderTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
https://android-review.googlesource.com/3250460
Branch: androidx-main
commit 4cf96f31d0cb929e120a5f4f531093e70ff0f61e
Author: Clara Fok <clarafok@google.com>
Date: Fri Aug 30 14:40:35 2024
Fix startDestination missing required arguments
When navigating to a NavGraph, after parsing the arguments (if any) from startDestination, we check to see if there are any missing required arguments (arguments that are non-nullable and do not have a default value).
Besides adding new tests, some existing tests have been refactored in either of the following 2 ways:
1. tests that tests for and allows startDestinations with misisng required args are now refactored to expect a missing arg exception
2. tests for behaviors unrelated to startDestination but has a startDestination with missing args is refactored to provide the required starting args
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 362594265
Relnote: "The route passed to a NavGraph's startDestination must contain the values for all required arguments, which are arguments that are non-nullable and don't have a default value."
Change-Id: I18e7401ac7a4d322db2add9b0f2781196d4d3257
M navigation/navigation-common/src/main/java/androidx/navigation/NavGraphNavigator.kt
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavGraphBuilderTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerRouteTest.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
cl...@google.com <cl...@google.com> #3
Fixed internally and will be available in navigation 2.8.1
na...@google.com <na...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-runtime:2.8.1
na...@google.com <na...@google.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-common:2.9.0-alpha01
androidx.navigation:navigation-compose:2.9.0-alpha01
Description
In this fix start destination args are now processed and stored into bundle. However, missing required arguments in startDestination is not caught during runtime when:
startRoute == startDestination.route here . We assume placeholders will fallback to default value but we don't verify if default values are present.
matchingArgs == null here . We proceed to navigate with the resulting bundle not containing required args.
Repro test:
Test should throw due to missing Int arg but it completes successfully.