Skip to content

Fix CmdPal gallery crash when extension has no homepage#48869

Open
niels9001 wants to merge 1 commit into
mainfrom
niels9001-fix-cmdpal-gallery-crash
Open

Fix CmdPal gallery crash when extension has no homepage#48869
niels9001 wants to merge 1 commit into
mainfrom
niels9001-fix-cmdpal-gallery-crash

Conversation

@niels9001

@niels9001 niels9001 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Selecting an extension in the CmdPal Extension Gallery crashed the app when that extension had no homepage defined.

Root cause

In ExtensionGalleryItemPage.xaml, the "View repository" HyperlinkButton bound its NavigateUri (a System.Uri) directly to the raw string property ViewModel.Homepage:

NavigateUri="{x:Bind ViewModel.Homepage, Mode=OneWay}"

x:Bind evaluates all bindings on an element regardless of Visibility, and to assign a string to a Uri target it generates a new Uri(value) conversion. When homepage is undefined, Homepage is null, so the binding executes new Uri(null)ArgumentNullException → the page crashes on load. The Visibility="{... HasHomepage}" collapse did not help because the NavigateUri binding still runs.

Every other NavigateUri x:Bind in the codebase (Link, LinkUri) is already bound to a Uri?, so the homepage hyperlink was the lone offender.

Fix

  • ExtensionGalleryItemViewModel.cs — Added a validated Uri? HomepageUri property backed by the existing _homepageHttpUri (already null for missing or non-web homepages).
  • ExtensionGalleryItemPage.xaml — Bound NavigateUri to ViewModel.HomepageUri instead of the raw string. null is valid for NavigateUri, so no conversion occurs. The tooltip still shows the Homepage string.
  • Tests — Added coverage asserting HomepageUri is set for a web homepage and null when missing.

Verification

  • Microsoft.CmdPal.UI.ViewModels, Microsoft.CmdPal.UI (XAML compile), and the unit test project all built cleanly (x64/Release, exit code 0).
  • All 24 ExtensionGalleryItemViewModelTests pass, including the two new cases.
  • Manually verified in VS that opening an extension without a homepage no longer crashes.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

gallery-crash.mp4

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>
@github-actions github-actions Bot added the Product-Command Palette Refers to the Command Palette utility label Jun 25, 2026
@niels9001 niels9001 requested a review from michaeljolley June 25, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants