Skip to content

Crash: "Failed to construct 'URL': Invalid URL" when adding repo with non-git@ SSH remote #97

@coocoo1112

Description

@coocoo1112

The problem

When adding an existing repository whose git remote uses a non-standard SSH github enterprise username
(e.g. org-123@github.[org].com:[repo].git instead of the typical
git@host:path), the app crashes immediately with an unrecoverable error:

TypeError: Failed to construct 'URL': Invalid URL
at isTrustedRemoteHost (app/src/lib/api.ts)
at getNonGitHubUrl (app/src/models/repository.ts)
at renderViewInBrowser (app/src/ui/changes/no-changes.tsx)

Root cause: getNonGitHubUrl in repository.ts only converts SSH URLs that start
with git@ to HTTPS before passing them to isTrustedRemoteHost. URLs using a
different SSH username fall through unconverted, and isTrustedRemoteHost then calls
new window.URL(rawSshUrl) with no try/catch, which throws on the bare SSH string.

Release version

3.5.7-r1

Operating system and distro

Windows 11

Steps to reproduce the behavior

First, I installed GitHub Desktop Plus using winget and I was able to log in to my github enterprise account. Following that I reached the main "Let's get started" page and clicked the "add an existing repository from your local drive..." button, but that immediately caused the below crash.

Image

This crash then persists through uninstall/reinstall cycles unless the %APPDATA%/Roaming/Github Desktop Plus directory is removed.

If I update the remote origin to https based URL, it works fine.

Specific to GitHub Desktop Plus?

Specific to Github Desktop Plus. All of these repos work for me in normal Github Desktop

Log files

No response

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions