Fix name reservation pipeline failing to detect unregistered packages#45933
Merged
Fix name reservation pipeline failing to detect unregistered packages#45933
Conversation
…ceptions
PyPIClient.project() returns {'message': 'Not Found'} for non-existent
packages without raising an exception. The _is_on_pypi function only
checked for exceptions, so it incorrectly treated all packages as already
registered on PyPI, preventing name reservation for new packages like
azure-mgmt-appnetwork.
Fix: check for 'info' key in the response, which is only present for
valid PyPI projects.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the name reservation discovery script used by the daily publish-namereserve-package.yml pipeline so it correctly identifies packages that are not registered on PyPI (e.g., azure-mgmt-appnetwork), preventing missed registrations.
Changes:
- Update
_is_on_pypi()to validate PyPI JSON responses by checking for the"info"key in the decoded payload. - Treat
"message": "Not Found"(404 JSON body) responses as “not on PyPI” rather than implicitly assuming success.
ChenxiJiang333
approved these changes
Mar 26, 2026
Ari4ka
approved these changes
Mar 26, 2026
fafhrd91
pushed a commit
to fafhrd91/azure-sdk-for-python
that referenced
this pull request
Apr 28, 2026
…ceptions (Azure#45933) PyPIClient.project() returns {'message': 'Not Found'} for non-existent packages without raising an exception. The _is_on_pypi function only checked for exceptions, so it incorrectly treated all packages as already registered on PyPI, preventing name reservation for new packages like azure-mgmt-appnetwork. Fix: check for 'info' key in the response, which is only present for valid PyPI projects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
The daily name reservation pipeline (
publish-namereserve-package.yml) fails to register new packages likeazure-mgmt-appnetworkon PyPI because_is_on_pypi()indiscover_unpublished_packages.pyincorrectly treats all packages as already registered.Root Cause
PyPIClient.project()does not raise an exception when a package doesn't exist on PyPI. Instead, the PyPI API returns HTTP 404 with a JSON body{"message": "Not Found"}, which is silently decoded. The_is_on_pypi()function only checked for exceptions, so it always returnedTrue— even for packages that don't exist.Fix
Check the response content: a valid PyPI project response contains an
"info"key, while a 404 response contains{"message": "Not Found"}. Changed_is_on_pypi()to verify"info" in resultinstead of assuming success when no exception is raised.Validation
Tested locally:
azure-core(exists on PyPI) → correctly returnsTrueazure-mgmt-appnetwork(not on PyPI) → now correctly returnsFalseazure-mgmt-appnetworkis now included in the registration listTest for azure-mgmt-appnetwork and now it could be found: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6066615&view=results