From 335e23e839235d07d69fdfe1b95c8e36f4b74cb4 Mon Sep 17 00:00:00 2001 From: v-davit-ioramashvili Date: Mon, 17 Aug 2026 22:05:27 +0400 Subject: [PATCH] =?UTF-8?q?[Windows]=20Fix=20MongoDB=20installer=20after?= =?UTF-8?q?=20release-notes=20URL=20and=20anchor=20ch=E2=80=A6=20(#14561)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Windows] Fix MongoDB installer after release-notes URL and anchor change The release-notes URL with a trailing slash now answers 308 Permanent Redirect, which Invoke-WebRequest on Windows PowerShell 5.1 does not follow, so the install fails on windows-2025, windows-2025-vs2026 and windows-2022. The release anchors on that page also lost their dots (#7040---aug-11-2026), so the old parser matched nothing. Use the canonical URL without the trailing slash and read versions from the changelog anchors (#std-label-7.0.40-changelog), which keep the dotted version. Also pick the highest version rather than the first on the page, and fail with a clear message when nothing parses. * Resolve MongoDB version from the downloads feed instead of the docs page Addresses review feedback. Scraping the release-notes page has now broken twice: the URL with a trailing slash answers 308 Permanent Redirect, which Invoke-WebRequest on PowerShell 5.1 does not follow, and the release anchors lost their dots so the parser matched nothing. https://downloads.mongodb.org/current.json lists the newest release of each supported branch, so it is not subject to the markup and URL changes that broke scraping. --------- Co-authored-by: Davit Ioramashvili <294214454+v-davit-ioramashvili@users.noreply.github.com> --- .../windows/scripts/build/Install-MongoDB.ps1 | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/images/windows/scripts/build/Install-MongoDB.ps1 b/images/windows/scripts/build/Install-MongoDB.ps1 index a45dbc5623..d1bd27897c 100644 --- a/images/windows/scripts/build/Install-MongoDB.ps1 +++ b/images/windows/scripts/build/Install-MongoDB.ps1 @@ -7,20 +7,21 @@ $toolsetContent = Get-ToolsetContent $toolsetVersion = $toolsetContent.mongodb.version -$getMongoReleases = Invoke-WebRequest -Uri "mongodb.com/docs/v$toolsetVersion/release-notes/$toolsetVersion/" -UseBasicParsing -$targetReleases = $getMongoReleases.Links.href | Where-Object { $_ -like "#$toolsetVersion*---*" } - -$minorVersions = @() -foreach ($release in $targetReleases) { - if ($release -notlike "*upcoming*") { - $pattern = '\d+\.\d+\.\d+' - $version = $release | Select-String -Pattern $pattern -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value } - $minorVersions += $version - } +# Resolve the latest patch release from the downloads feed rather than the release notes +# page. The feed lists the newest release of each supported branch and is not subject to the +# markup and URL changes that repeatedly broke scraping the docs. +$mongoReleasesUrl = "https://downloads.mongodb.org/current.json" +$mongoReleases = Invoke-RestMethod -Uri $mongoReleasesUrl + +$latestVersion = $mongoReleases.versions.version | + Where-Object { $_ -like "$toolsetVersion.*" } | + Sort-Object { [version]$_ } -Descending | + Select-Object -First 1 + +if (-not $latestVersion) { + throw "Unable to resolve latest MongoDB $toolsetVersion release from $mongoReleasesUrl" } -$latestVersion = $minorVersions[0] - Install-Binary ` -Url "https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-$latestVersion-signed.msi" ` -ExtraInstallArgs @('TARGETDIR=C:\PROGRA~1\MongoDB ADDLOCAL=ALL') `