Skip to content

Conversation

@eramongodb
Copy link
Contributor

@eramongodb eramongodb commented Aug 12, 2025

Ongoing GitHub API issues appear to have revealed a potential script bug in mongosh_dl.py where a call to _get_latest_version() may return None, e.g.:

INFO Downloading mongosh... INFO Download latest mongosh for linux-x86_64 INFO Download url: https://downloads.mongodb.com/compass/mongosh-None-linux-x64.tgz ERROR Failed to download [https://downloads.mongodb.com/compass/mongosh-None-linux-x64.tgz] 

The only way I see _get_latest_version() can return None (when not taking the _get_latest_version_git() branch) is if the for item in data loop falls-through to the end of the function. I do not know what the response could be such that the API request succeeds (otherwise urllib.request.urlopen() should raise an URLError) and returns valid JSON (otherwise json.loads() should raise an JSONDecodeError), yet the contents do not contain any array element with a tag_name (or possibly does not contain any array elements at all...?). Therefore, this PR proposes printing the contents of data on error to assist with debugging this condition if it occurs again + raising an exception to fail-early when no tag_name is found (avoid attempting to download+cache an invalid URL).

@eramongodb eramongodb requested a review from blink1073 August 12, 2025 16:43
@eramongodb eramongodb self-assigned this Aug 12, 2025
@eramongodb
Copy link
Contributor Author

eramongodb commented Aug 12, 2025

It looks like GitHub Actions encountered the error:

RuntimeError: Could not find tag name in releases: [] 

This means the GitHub API request is "succeeding" by returning an empty JSON array...? I now wonder if json.loads() may be obsuring details in the raw response rather than actually being an empty JSON array. (Added a LOGGER.debug() call to capture the raw response for future inspection.)

Updated the proposed PR changes to perform a "length" check via conversion to bool (only JSON values of non-zero int, non-zero float, non-empty string, or true will incorrectly fail the check; such cases would mean the GitHub API is behaving even more strangely than it already is). The search for tag_name is moved into the try-catch block so that it can reuse the fallback to git tags.

@eramongodb eramongodb changed the title Raise RuntimeError when tag_name is missing in releases Use git tags when GitHub API returns an empty list of releases Aug 12, 2025
@blink1073 blink1073 requested review from NoahStapp and removed request for blink1073 August 13, 2025 15:25
@eramongodb eramongodb merged commit 61eacf1 into mongodb-labs:master Aug 14, 2025
77 checks passed
@eramongodb eramongodb deleted the det-mongosh_dl branch August 14, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants