Fix CmdPal gallery crash when extension has no homepage#48869
Open
niels9001 wants to merge 1 commit into
Open
Conversation
The gallery item detail page bound HyperlinkButton.NavigateUri (a Uri) directly to the raw Homepage string. x:Bind evaluates all bindings regardless of element visibility, so for extensions without a homepage the generated string-to-Uri conversion ran new Uri(null), throwing ArgumentNullException and crashing the page. Bind NavigateUri to a new validated Uri? HomepageUri property (backed by the existing _homepageHttpUri) so null is passed through without conversion. Add unit tests covering the populated and missing homepage cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
michaeljolley
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Selecting an extension in the CmdPal Extension Gallery crashed the app when that extension had no
homepagedefined.Root cause
In
ExtensionGalleryItemPage.xaml, the "View repository"HyperlinkButtonbound itsNavigateUri(aSystem.Uri) directly to the raw string propertyViewModel.Homepage:NavigateUri="{x:Bind ViewModel.Homepage, Mode=OneWay}"x:Bindevaluates all bindings on an element regardless ofVisibility, and to assign astringto aUritarget it generates anew Uri(value)conversion. Whenhomepageis undefined,Homepageisnull, so the binding executesnew Uri(null)→ArgumentNullException→ the page crashes on load. TheVisibility="{... HasHomepage}"collapse did not help because theNavigateUribinding still runs.Every other
NavigateUrix:Bind in the codebase (Link,LinkUri) is already bound to aUri?, so the homepage hyperlink was the lone offender.Fix
ExtensionGalleryItemViewModel.cs— Added a validatedUri? HomepageUriproperty backed by the existing_homepageHttpUri(alreadynullfor missing or non-web homepages).ExtensionGalleryItemPage.xaml— BoundNavigateUritoViewModel.HomepageUriinstead of the raw string.nullis valid forNavigateUri, so no conversion occurs. The tooltip still shows theHomepagestring.HomepageUriis set for a web homepage andnullwhen missing.Verification
Microsoft.CmdPal.UI.ViewModels,Microsoft.CmdPal.UI(XAML compile), and the unit test project all built cleanly (x64/Release, exit code 0).ExtensionGalleryItemViewModelTestspass, including the two new cases.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
gallery-crash.mp4