Skip to content

fix(@angular/cli): ignore registry manifests that do not match the requested version - #34617

Open
MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/registry-manifest-version-mismatch
Open

MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/registry-manifest-version-mismatch

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Modern yarn returns the manifest of the latest version instead of an error when the requested version or range does not exist (for example, yarn npm info @angular/core@99.99.99 prints the latest version with exit code 0). As a result, ng add and ng update could continue with an unrelated version instead of reporting that the requested version does not exist.

Return null from getRegistryManifest when the fetched version does not satisfy the requested version or range.

…quested version

Modern yarn returns the manifest of the latest version instead of an error when
the requested version or range does not exist (for example,
`yarn npm info @angular/core@99.99.99` prints the latest version with exit code
0). As a result, `ng add` and `ng update` could continue with an unrelated
version instead of reporting that the requested version does not exist.

Return `null` from `getRegistryManifest` when the fetched version does not
satisfy the requested version or range.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an issue where modern yarn returns the latest version instead of throwing an error when a requested package version does not exist. It adds a check in PackageManager.getRegistryManifest to return null if the fetched manifest version does not satisfy the requested version range, and includes corresponding unit tests. Feedback suggests defensively validating manifest.version using valid() before calling satisfies to prevent potential runtime TypeError crashes.

Comment on lines +568 to +574
if (
manifest &&
validRange(version) &&
!satisfies(manifest.version, version, { includePrerelease: true })
) {
return null;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

semver.satisfies throws a TypeError if the version argument is not a valid semver string. To prevent potential runtime crashes when encountering malformed or unexpected registry manifests, we should defensively verify that manifest.version is valid using valid(manifest.version) before calling satisfies.

Suggested change
if (
manifest &&
validRange(version) &&
!satisfies(manifest.version, version, { includePrerelease: true })
) {
return null;
}
if (
manifest &&
valid(manifest.version) &&
validRange(version) &&
!satisfies(manifest.version, version, { includePrerelease: true })
) {
return null;
}

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Oct 30, 2026
@alan-agius4
alan-agius4 requested a review from clydin October 30, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/cli target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants