Skip to content

fix(release): add null-safe fallback for version in createGitTagValues#34598

Merged
jaysoo merged 3 commits intomasterfrom
fix-nx-release-tag-interpolation
Feb 25, 2026
Merged

fix(release): add null-safe fallback for version in createGitTagValues#34598
jaysoo merged 3 commits intomasterfrom
fix-nx-release-tag-interpolation

Conversation

@Coly010
Copy link
Copy Markdown
Contributor

@Coly010 Coly010 commented Feb 25, 2026

Current Behavior

When nx release runs with docker-configured projects (either via explicit config or
@nx/docker plugin inference), git tags are created with the literal string {version}
instead of the actual version number (e.g., v{version} instead of v1.0.6, or
app-3@{version} instead of [email protected]).

This happens because:

  1. If ANY project in a release group has docker config, preferDockerVersion is auto-set to
    true for the ENTIRE group
  2. createGitTagValues() then blindly selects projectVersionData.dockerVersion, which is
    null for non-docker projects (or projects with no changes)
  3. The interpolate() function receives null for {version} and returns the literal
    placeholder unchanged

Commit messages are unaffected because createCommitMessageValues() only uses newVersion and
already guards against null. The changelog code (changelog.ts:1117-1121) also already has
the correct null-safe pattern.

Expected Behavior

When preferDockerVersion is true but dockerVersion is null, git tags should fall back to
using newVersion instead of producing literal {version} placeholders. When both versions
are null, no tag should be created.

For mixed release groups (some projects have docker config, some don't), the auto-enable
logic should use 'both' mode instead of true, which already has proper null-safe checks for
each version type.

Changes

  • shared.ts: Added null-safe fallback (??) in createGitTagValues() for both independent and
    fixed group code paths, plus a guard to skip tag creation when both versions are null
  • config.ts: Refined auto-enable logic to check whether ALL or only SOME projects have
    docker config — mixed groups now get 'both' mode instead of true
  • shared.spec.ts: Added 5 test cases covering null version fallback scenarios for fixed
    groups, independent groups, both-null, reverse fallback, and mixed groups

Related Issue(s)

Fixes #34382
Fixes #33890
Fixes #34391

When preferDockerVersion is true but dockerVersion is null (e.g. for
non-docker projects in a group with docker projects), the interpolate()
function receives null for {version} and returns the literal placeholder
string "{version}" in git tags instead of the actual version number.

Apply the same null-safe pattern already used in changelog.ts: fall back
to newVersion when dockerVersion is null (and vice versa), and skip tag
creation entirely when both are null.

Fixes #34382
Fixes #33890
Fixes #34391
When auto-enabling preferDockerVersion, distinguish between groups where
ALL projects have docker config vs only SOME. Mixed groups now use
'both' mode which already has proper null-safe checks for each version
type, preventing literal {version} tags for non-docker projects.
Add five test cases covering:
- preferDockerVersion=true with null dockerVersion (fixed group)
- preferDockerVersion=true with null dockerVersion (independent group)
- Both versions null with preferDockerVersion=true
- preferDockerVersion=false with null newVersion
- Mixed independent group with some docker and some non-docker projects
@Coly010 Coly010 requested a review from a team as a code owner February 25, 2026 11:46
@Coly010 Coly010 requested a review from AgentEnder February 25, 2026 11:46
@Coly010 Coly010 self-assigned this Feb 25, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 25, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 791b585
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/699ee10bb2beda000885076d
😎 Deploy Preview https://deploy-preview-34598--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.

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 25, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 791b585
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/699ee10b43b16b0008c2e157
😎 Deploy Preview https://deploy-preview-34598--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.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Feb 25, 2026

View your CI Pipeline Execution ↗ for commit 791b585

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

☁️ Nx Cloud last updated this comment at 2026-02-25 14:04:17 UTC

@jaysoo jaysoo merged commit df9eb0b into master Feb 25, 2026
26 of 27 checks passed
@jaysoo jaysoo deleted the fix-nx-release-tag-interpolation branch February 25, 2026 14:10
FrozenPandaz pushed a commit that referenced this pull request Feb 26, 2026
#34598)

## Current Behavior

When nx release runs with docker-configured projects (either via
explicit config or
@nx/docker plugin inference), git tags are created with the literal
string {version}
instead of the actual version number (e.g., v{version} instead of
v1.0.6, or
  app-3@{version} instead of [email protected]).

  This happens because:

1. If ANY project in a release group has docker config,
preferDockerVersion is auto-set to
  true for the ENTIRE group
2. createGitTagValues() then blindly selects
projectVersionData.dockerVersion, which is
  null for non-docker projects (or projects with no changes)
3. The interpolate() function receives null for {version} and returns
the literal
  placeholder unchanged

Commit messages are unaffected because createCommitMessageValues() only
uses newVersion and
already guards against null. The changelog code (changelog.ts:1117-1121)
also already has
  the correct null-safe pattern.

 ## Expected Behavior

When preferDockerVersion is true but dockerVersion is null, git tags
should fall back to
using newVersion instead of producing literal {version} placeholders.
When both versions
  are null, no tag should be created.

For mixed release groups (some projects have docker config, some don't),
the auto-enable
logic should use 'both' mode instead of true, which already has proper
null-safe checks for
   each version type.

 ## Changes

- shared.ts: Added null-safe fallback (??) in createGitTagValues() for
both independent and
fixed group code paths, plus a guard to skip tag creation when both
versions are null
- config.ts: Refined auto-enable logic to check whether ALL or only SOME
projects have
  docker config — mixed groups now get 'both' mode instead of true
- shared.spec.ts: Added 5 test cases covering null version fallback
scenarios for fixed
groups, independent groups, both-null, reverse fallback, and mixed
groups

 ## Related Issue(s)

  Fixes #34382
  Fixes #33890
  Fixes #34391

(cherry picked from commit df9eb0b)
FrozenPandaz pushed a commit that referenced this pull request Feb 26, 2026
#34598)

## Current Behavior

When nx release runs with docker-configured projects (either via
explicit config or
@nx/docker plugin inference), git tags are created with the literal
string {version}
instead of the actual version number (e.g., v{version} instead of
v1.0.6, or
  app-3@{version} instead of [email protected]).

  This happens because:

1. If ANY project in a release group has docker config,
preferDockerVersion is auto-set to
  true for the ENTIRE group
2. createGitTagValues() then blindly selects
projectVersionData.dockerVersion, which is
  null for non-docker projects (or projects with no changes)
3. The interpolate() function receives null for {version} and returns
the literal
  placeholder unchanged

Commit messages are unaffected because createCommitMessageValues() only
uses newVersion and
already guards against null. The changelog code (changelog.ts:1117-1121)
also already has
  the correct null-safe pattern.

 ## Expected Behavior

When preferDockerVersion is true but dockerVersion is null, git tags
should fall back to
using newVersion instead of producing literal {version} placeholders.
When both versions
  are null, no tag should be created.

For mixed release groups (some projects have docker config, some don't),
the auto-enable
logic should use 'both' mode instead of true, which already has proper
null-safe checks for
   each version type.

 ## Changes

- shared.ts: Added null-safe fallback (??) in createGitTagValues() for
both independent and
fixed group code paths, plus a guard to skip tag creation when both
versions are null
- config.ts: Refined auto-enable logic to check whether ALL or only SOME
projects have
  docker config — mixed groups now get 'both' mode instead of true
- shared.spec.ts: Added 5 test cases covering null version fallback
scenarios for fixed
groups, independent groups, both-null, reverse fallback, and mixed
groups

 ## Related Issue(s)

  Fixes #34382
  Fixes #33890
  Fixes #34391

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

github-actions bot commented Mar 3, 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 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants