Skip to content

Commit 8b00d1b

Browse files
renemadsenclaude
andcommitted
fix(cronjob.py): use NuGet search API to get only listed stable versions
Avoids picking junk unlisted versions like System.ComponentModel.Composition 2010.2.11.1 that the flat-container API returned. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 17702d0 commit 8b00d1b

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

cronjob.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,26 @@ def read_package_references(csproj_path):
6262

6363

6464
def get_latest_stable_version(package_name):
65-
url = f"https://api.nuget.org/v3-flatcontainer/{package_name.lower()}/index.json"
65+
# Use the NuGet search API instead of the flat-container API: it returns
66+
# only *listed* packages in proper semver order, which filters out the
67+
# junk old versions (e.g. `2010.2.11.1`) that the flat container still
68+
# includes in its raw `versions` array.
69+
url = (
70+
"https://azuresearch-usnc.nuget.org/query"
71+
f"?q=packageid:{package_name}"
72+
"&prerelease=false"
73+
"&take=1"
74+
)
6675
response = requests.get(url, timeout=30)
6776
if response.status_code != 200:
6877
return None
69-
stable = [v for v in response.json().get("versions", []) if "-" not in v]
70-
return stable[-1] if stable else None
78+
data = response.json().get("data", [])
79+
if not data:
80+
return None
81+
version = data[0].get("version")
82+
if version and "-" in version:
83+
return None
84+
return version
7185

7286

7387
def update_csproj_versions(csproj_path, bumps):

0 commit comments

Comments
 (0)