Skip to content

fix(core): support canonical SSH URLs when extracting GitHub user/repo slug during nx release#31684

Merged
jaysoo merged 6 commits intonrwl:masterfrom
ekkolon:fix/nx-release-canonical-ssh-remotes
Feb 27, 2026
Merged

fix(core): support canonical SSH URLs when extracting GitHub user/repo slug during nx release#31684
jaysoo merged 6 commits intonrwl:masterfrom
ekkolon:fix/nx-release-canonical-ssh-remotes

Conversation

@ekkolon
Copy link
Copy Markdown
Contributor

@ekkolon ekkolon commented Jun 22, 2025

Current Behavior

When running nx release with Git remotes configured as canonical SSH URLs, the repository slug is extracted incorrectly.

Examples of affected remotes include:

In these cases, the existing regex-based logic misinterprets the port number as part of the repository path (for example: 443/org). This causes the release creation request to be built with an invalid repository slug and results in 404 Not Found errors from the GitHub or GitLab APIs.

Expected Behavior

nx release should correctly extract the repository slug from all valid Git remote URL formats, regardless of whether the remote uses HTTPS, SCP-style SSH, or fully qualified SSH URLs with explicit ports.

Valid examples should resolve to the correct slug:

Users should not need to modify their Git remote configuration in order for nx release to work correctly.

What’s Changed

  • Introduced a shared utility (extractRepoSlug) to consistently extract repository slugs from Git remote URLs.
  • Replaced provider-specific, regex-based parsing in:
    • GithubRemoteReleaseClient
    • GitLabRemoteReleaseClient
  • Added support for:
    • HTTPS remotes
    • SCP-style SSH remotes (git@host:org/repo.git)
    • Fully qualified SSH URLs with custom ports
    • Arbitrarily nested GitLab group and subgroup paths
    • Self-hosted GitHub and GitLab instances via hostname matching
  • Added comprehensive unit tests covering valid and invalid URL formats for both providers.

Related Issue(s)

Fixes #31682

@ekkolon ekkolon requested a review from a team as a code owner June 22, 2025 19:58
@ekkolon ekkolon requested a review from xiongemi June 22, 2025 19:58
@vercel
Copy link
Copy Markdown

vercel bot commented Jun 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nx-dev Ready Ready Preview Jan 26, 2026 7:30am

Request Review

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Jun 22, 2025

View your CI Pipeline Execution ↗ for commit d9002e7

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 56m 24s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 15s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-27 03:10:48 UTC

@FrozenPandaz FrozenPandaz added the priority: medium Medium Priority (not high, not low priority) label Jun 23, 2025
@ekkolon ekkolon changed the title fix(nx): support canonical SSH URLs when extracting GitHub user/repo slug during nx release fix(core): support canonical SSH URLs when extracting GitHub user/repo slug during nx release Jun 23, 2025
@ekkolon ekkolon marked this pull request as draft June 27, 2025 07:51
@ekkolon ekkolon force-pushed the fix/nx-release-canonical-ssh-remotes branch from 324464f to cb600fb Compare June 27, 2025 14:14
@ekkolon ekkolon force-pushed the fix/nx-release-canonical-ssh-remotes branch from cb600fb to a0d2b35 Compare July 4, 2025 08:28
@github-actions github-actions bot added the stale label Jan 1, 2026
@github-actions github-actions bot closed this Jan 23, 2026
@JamesHenry JamesHenry reopened this Jan 25, 2026
@JamesHenry JamesHenry removed the stale label Jan 25, 2026
@JamesHenry
Copy link
Copy Markdown
Collaborator

@ekkolon I didn't want this one to just be auto-closed but at the same time you never promoted it out of draft - is closing the correct course of action here or will you have chance to finalize it?

@ekkolon
Copy link
Copy Markdown
Contributor Author

ekkolon commented Jan 26, 2026

Hey @JamesHenry, thanks for the nudge. I plan to finalize this and move it out of draft shortly. Please keep it open.

@netlify
Copy link
Copy Markdown

netlify bot commented Jan 26, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit d9002e7
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69a0b0ddf703170008fed2b3
😎 Deploy Preview https://deploy-preview-31684--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ekkolon ekkolon marked this pull request as ready for review January 26, 2026 08:50
@ekkolon ekkolon requested a review from Coly010 as a code owner January 26, 2026 08:50
jaysoo

This comment was marked as outdated.

@jaysoo jaysoo force-pushed the fix/nx-release-canonical-ssh-remotes branch from 750c43a to e1154f4 Compare February 26, 2026 18:20
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 26, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit d9002e7
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69a0b0dd666c6f000851742d
😎 Deploy Preview https://deploy-preview-31684--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ekkolon
Copy link
Copy Markdown
Contributor Author

ekkolon commented Feb 26, 2026

Great refactoring — the shared extract-repo-slug.ts with support for SCP-like, HTTPS, and canonical SSH URLs (with ports) is well done. The 30+ test cases give good coverage.

Regression bug: In the GitLab hostname handling, there's a missing fallback:

hostname = createReleaseConfig.hostname

This should be:

hostname = createReleaseConfig.hostname || hostname

Without the || hostname fallback, if createReleaseConfig.hostname is undefined, it breaks GitLab release URL generation. Fix that one line and this is ready to go.

Thanks! This also affects the GitHub hostname handling. I'll apply the same fallback there too.

@ekkolon ekkolon requested a review from jaysoo February 26, 2026 19:52
…slug during `nx release`

Previously, the `nx release` command failed to create GitHub releases when the Git remote was configured using a canonical SSH-over-HTTPS URL (e.g. ssh://[email protected]:443/user/repo.git).

The regex in `GithubRemoteReleaseClient.resolveRepoData()` failed to correctly extract the `user/repo` slug from these URLs. As a result, the release creation request was built with an incorrect slug (e.g. `443/user`) and the GitHub API call failed.

This commit fixes the issue by extending the regex to handle fully qualified SSH URLs returned by `git remote get-url`, including cases where SSH is tunneled over HTTPS on port 443.

It also adds unit tests to cover:
- Successful parsing of canonical SSH URL formats
- Graceful fallback on match failure
- Malformed or non-GitHub remote URLs

Closes #31682
@ekkolon ekkolon force-pushed the fix/nx-release-canonical-ssh-remotes branch from 4fb4cb6 to d9002e7 Compare February 26, 2026 20:45
@jaysoo jaysoo merged commit 8255c28 into nrwl:master Feb 27, 2026
24 checks passed
@ekkolon ekkolon deleted the fix/nx-release-canonical-ssh-remotes branch February 27, 2026 14:16
FrozenPandaz pushed a commit that referenced this pull request Mar 4, 2026
…o slug during `nx release` (#31684)

## Current Behavior

When running `nx release` with Git remotes configured as **canonical SSH
URLs**, the repository slug is extracted incorrectly.

Examples of affected remotes include:

- `ssh://[email protected]:443/org/repo.git`
- `ssh://[email protected]:2222/group/subgroup/repo.git`

In these cases, the existing regex-based logic misinterprets the port
number as part of the repository path (for example: `443/org`). This
causes the release creation request to be built with an invalid
repository slug and results in `404 Not Found` errors from the GitHub or
GitLab APIs.

## Expected Behavior

`nx release` should correctly extract the repository slug from all valid
Git remote URL formats, regardless of whether the remote uses HTTPS,
SCP-style SSH, or fully qualified SSH URLs with explicit ports.

Valid examples should resolve to the correct slug:

- `ssh://[email protected]:443/org/repo.git` => `org/repo`
- `ssh://[email protected]:2222/group/subgroup/repo.git`=>
`group/subgroup/repo`

Users should not need to modify their Git remote configuration in order
for `nx release` to work correctly.

## What’s Changed

- Introduced a shared utility
([`extractRepoSlug`](https://github.com/nrwl/nx/pull/31684/changes#diff-799188c178b8a084e86dbe9063ec88a7c324212a8ef79729777f56e4bf7f455cR29-R60))
to consistently extract repository slugs from Git remote URLs.
- Replaced provider-specific, regex-based parsing in:
  - `GithubRemoteReleaseClient`
  - `GitLabRemoteReleaseClient`
- Added support for:
  - HTTPS remotes
  - SCP-style SSH remotes (`git@host:org/repo.git`)
  - Fully qualified SSH URLs with custom ports
  - Arbitrarily nested GitLab group and subgroup paths
  - Self-hosted GitHub and GitLab instances via hostname matching
- Added comprehensive unit tests covering valid and invalid URL formats
for both providers.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #31682

(cherry picked from commit 8255c28)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 5, 2026

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

priority: medium Medium Priority (not high, not low priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nx release fails to create GitHub releases with Git remotes pointing to fully qualified SSH URLs

4 participants