Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ng-dev/misc/sync-module-bazel/sync-module-bazel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ async function processNodeToolchainArgs(
return args;
}

if (!semver.valid(effectiveVersion)) {
throw new Error(`Invalid Node.js version: ${effectiveVersion}`);
}
Comment on lines +142 to +144
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

While semver.valid() validates the version, it also returns the cleaned/normalized version string (e.g., stripping any leading v or whitespace). If effectiveVersion contains a leading v (for example, if manually specified in MODULE.bazel), using it directly in getNodeJsRepositories will result in a URL with a double v prefix (e.g., vv24.16.0), causing the fetch to fail.

To prevent this, we should assign the normalized version returned by semver.valid() back to effectiveVersion.

Suggested change
if (!semver.valid(effectiveVersion)) {
throw new Error(`Invalid Node.js version: ${effectiveVersion}`);
}
const validatedVersion = semver.valid(effectiveVersion);
if (!validatedVersion) {
throw new Error('Invalid Node.js version: ' + effectiveVersion);
}
effectiveVersion = validatedVersion;


Log.info(`Resolving Node.js repositories for v${effectiveVersion}...`);
const repositories = await getNodeJsRepositories(effectiveVersion);
const lines = repositories.map(({filename, sha, type}) => {
Expand Down