Skip to content

feat: implement handling for deprecated versions in version selection logic#16247

Open
skywing918 wants to merge 6 commits into
mainfrom
kyle/skipDeprecatedVersions
Open

feat: implement handling for deprecated versions in version selection logic#16247
skywing918 wants to merge 6 commits into
mainfrom
kyle/skipDeprecatedVersions

Conversation

@skywing918

Copy link
Copy Markdown
Contributor

fixes #15981

Summary

npm deprecate marks a version but does not move dist-tags. So dist-tags.latest / beta / next can still point to a deprecated version that has no matching CHANGELOG entry or git-tag content. The JS release tooling used that version as the changelog / breaking-change baseline, causing the failures reported in #15981.

Real example (from #15981)

@azure/arm-computeschedule — the beta dist-tag pointed to 1.2.0-beta.1, an accidentally published and later deprecated version that has no changelog. The changelog step then failed:

[WARN]: Failed to find NPM package's changelog '.../changelog-temp/next/package/CHANGELOG.md'
[INFO]: git --no-pager show @azure/arm-computeschedule_1.2.0-beta.1:sdk/computeschedule/arm-computeschedule/CHANGELOG.md
[WARN]: Command failed (attempt 1/3): ...

(The deprecated flag lives on the packument at versions["<ver>"].deprecated as a non-empty string.)

Handling logic

getLatestStableVersion and getNextBetaVersion are now deprecation-aware (src/utils/version.ts):

  • isVersionDeprecated(view, v)true when view.versions[v].deprecated is a non-empty string.
  • getLatestNonDeprecatedVersion(view, predicate) → newest (semver) non-deprecated version matching a channel predicate.
  • getNextBetaVersion: if the selected beta/next target is deprecated, fall back to the latest non-deprecated beta.
  • getLatestStableVersion: if the latest/beta target is deprecated, fall back to the latest non-deprecated GA, then to the latest non-deprecated beta.
  • Zero regression: the fallback only runs when a selected dist-tag target actually carries a deprecated field; every other case behaves exactly as before. If all candidates are deprecated (whole-package retirement), the original value is returned unchanged.

Tests

Added regression tests in src/test/version/version.test.ts covering the deprecated-latest and deprecated-beta fallback paths, plus a no-regression case.

Copilot AI review requested due to automatic review settings July 2, 2026 08:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the JS SDK release tooling’s npm version-selection helpers to treat npm deprecate-marked versions as invalid baselines, preventing changelog/breaking-change workflows from selecting deprecated dist-tag targets that may not have corresponding changelog content (fixing #15981).

Changes:

  • Add packument-aware detection of deprecated versions and a helper to select the newest non-deprecated version by semver.
  • Update getNextBetaVersion and getLatestStableVersion to fall back from deprecated dist-tag targets to non-deprecated candidates.
  • Add regression tests covering deprecated latest and beta fallback behavior plus a no-regression case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tools/js-sdk-release-tools/src/utils/version.ts Adds deprecation-aware version selection and fallback logic for latest/beta/next dist-tag baselines.
tools/js-sdk-release-tools/src/test/version/version.test.ts Adds regression tests for deprecated dist-tag fallback behavior and preserves prior expected selection behavior.

Comment thread tools/js-sdk-release-tools/src/utils/version.ts Outdated
Comment thread tools/js-sdk-release-tools/src/utils/version.ts
Comment thread tools/js-sdk-release-tools/src/test/version/version.test.ts
skywing918 and others added 5 commits July 2, 2026 16:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JS Release Tool / Breaking Change Detection May Fail Due to Accidentally Published Deprecated Versions

2 participants