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

[Blazor] Fix null reference exception caused by ambiguous routes #39833

Merged
merged 1 commit into from
Jan 28, 2022

Conversation

javiercn
Copy link
Member

When two Blazor routes are ambiguous the generated exception is obfuscated by following attempts to access the route table.

The reason this happens is that we update the route key before we compute a new table, and when the table fails, the next time we try the key, we return null.

The solution is to wait to set the key until we've successfully computed the route table to avoid hiding exceptions in that case.

@javiercn javiercn requested a review from a team as a code owner January 28, 2022 14:51
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Jan 28, 2022
Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

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

Could we add a unit test to verify this?

@javiercn
Copy link
Member Author

@pranavkm I looked into adding a test, but it is incredibly cumbersome as the routes get picked up from the assembly, and I don't think its worth creating an assembly for a test like this.

@javiercn javiercn enabled auto-merge (squash) January 28, 2022 17:31
@javiercn javiercn merged commit d3ce404 into main Jan 28, 2022
@javiercn javiercn deleted the javiercn/fix-routing-null-ref branch January 28, 2022 19:22
@ghost ghost added this to the 7.0-preview1 milestone Jan 28, 2022
@wtgodbe wtgodbe modified the milestones: 7.0-preview1, 7.0-preview2 Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants