-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Avoid null exception when href is null. #15765
Conversation
As I explained under the issue, that property shouldn't be null, to begin with. And if it is, we should throw a proper exception, because it's an invalid state for the menu, we shouldn't hide that. |
It won't be null if it was was added by the UI. But if you add it from other sources like migration, it could be null. The code should avoid throw an unexpected a null reference exception. |
Is it OK if it's null? I don't think a null |
It is not okay. But, we can incorrectly migrate a site with a null value outside the driver logic. Maybe line 12 should read this instead
this way if there is an incorrect null value, we treat it as |
That would explain how it can happen at all, but the corresponding issue is about Having
looks good, but this wouldn't yet fix the problem in the linked issue, just hide it. We can then merge this PR but I'd wait for the issue author to confirm what the root of the problem is. |
The root of the problem is storing incorrect value in the database. But, it is better if out code does not throw unexpected exception. So we can treat null as '#' so it does not break the app, but the menu item will not be useful. |
This isn't coming from the DB. Read from here: #15752 (comment) |
@Piedone yes we should understand how that menu item is added. But, I also think we should also take this PR |
That's what I also said :). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I'd like to give Italo more chance to reply under the issue. I'll merge this on Monday otherwise.
Fix #15752