Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Navigation] Check that all required arguments are present in the link #204

Conversation

osipxd
Copy link
Contributor

@osipxd osipxd commented Jun 20, 2021

Proposed Changes

Currently, we can open a destination with a link that doesn't contain the required arguments. In this case, we will get a crash in runtime. This commit adds check that all required arguments are present in the link.

After this change, deep links will require to contain all required arguments for a destination. Links not containing all required arguments will be ignored.

Testing

Test: ./gradlew test connectedCheck

Issues Fixed

Fixes: 185527157

@google-cla google-cla bot added the cla: yes label Jun 20, 2021
Comment on lines 315 to 324
val missingRequiredArguments = arguments.filterValues { !it.isDefaultValuePresent }
.keys
.filter { it !in navDeepLink.arguments }
require(missingRequiredArguments.isEmpty()) {
"Deep link ${navDeepLink.uriPattern} can't be used to open destination $this.\n" +
"Following required arguments are missing: $missingRequiredArguments"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be great to have a check like this to make sure deep links will be able to open this destination. But I'm not sure I've selected the right place for this. We can add the required parameters after deepLink is added to bypass this validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe also add validation after a new argument was added?

Copy link

Choose a reason for hiding this comment

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

Not sure why it wasn't caught in github, but this is failing a number of navigation-runtime test.

Screen Shot 2021-08-03 at 4 10 59 PM

I am thinking that our sample xml isn't realistic enough and we may need to add an argument to the deepLink that goes to second_test.

Copy link
Contributor Author

@osipxd osipxd Aug 16, 2021

Choose a reason for hiding this comment

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

@jbw0033, I've fixed tests in the latest commit (8339589), can you take a look if I did it right?

@osipxd osipxd changed the title Check that all required arguments are present in the link [Navigation] Check that all required arguments are present in the link Jun 20, 2021
Copy link
Contributor

@sanura-njaka sanura-njaka left a comment

Choose a reason for hiding this comment

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

Hi Osip, can you please rebase your changes?

@osipxd osipxd force-pushed the 185527157-check-required-args-in-deep-links branch from 482b430 to 32f58c4 Compare June 22, 2021 09:11
@osipxd
Copy link
Contributor Author

osipxd commented Jun 22, 2021

Hi Osip, can you please rebase your changes?

Done

@dlam
Copy link
Member

dlam commented Jun 30, 2021

Looks like there's a conflict - could you rebase your changes again?

@osipxd
Copy link
Contributor Author

osipxd commented Jul 5, 2021

Yes, I'll rebase it soon

@osipxd osipxd force-pushed the 185527157-check-required-args-in-deep-links branch 2 times, most recently from fa397d1 to 9010b95 Compare July 18, 2021 07:20
@osipxd
Copy link
Contributor Author

osipxd commented Jul 20, 2021

Requires #210 to be merged first

@osipxd osipxd force-pushed the 185527157-check-required-args-in-deep-links branch 2 times, most recently from 2a2d790 to 967d504 Compare July 21, 2021 09:56
@osipxd osipxd force-pushed the 185527157-check-required-args-in-deep-links branch from 967d504 to e11326c Compare July 29, 2021 06:05
@osipxd
Copy link
Contributor Author

osipxd commented Jul 29, 2021

It failed again after rebase. Something related to navigation-compose module:

Could not determine the dependencies of task ':navigation:navigation-compose:compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':navigation:navigation-compose:releaseCompileClasspath'.

@dlam, can you take a look?

@jbw0033
Copy link

jbw0033 commented Jul 29, 2021

I think this is on our side since the compose 1.0.1 release isn't yet available. I'll check on getting it resolved.

@jbw0033 jbw0033 self-requested a review July 29, 2021 22:08
Currently we can open destination with link that doesn't contain required arguments. In this case we will get crash in runtime. This commit adds check that all required arguments are present in link.

Test: ./gradlew test connectedCheck
Fixes: 185527157
@osipxd osipxd force-pushed the 185527157-check-required-args-in-deep-links branch from e11326c to 803d037 Compare August 16, 2021 06:33
@osipxd osipxd requested a review from jbw0033 August 16, 2021 10:35
@osipxd osipxd force-pushed the 185527157-check-required-args-in-deep-links branch from d1cced0 to 8339589 Compare August 16, 2021 10:39
@osipxd osipxd deleted the 185527157-check-required-args-in-deep-links branch August 18, 2021 06:52
@jbw0033
Copy link

jbw0033 commented Aug 18, 2021

Thank you for bearing with us to get this PR out @osipxd!

@svenjacobs
Copy link

I believe this change introduced a bug. Please see here.

@osipxd
Copy link
Contributor Author

osipxd commented Sep 11, 2021

@svenjacobs, looks like a duplicate of 198689811. This issue is already fixed. I think it will be included in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants