Skip to content

Fix name reservation pipeline failing to detect unregistered packages#45933

Merged
msyyc merged 1 commit intomainfrom
fix/namereserve-pypi-check
Mar 26, 2026
Merged

Fix name reservation pipeline failing to detect unregistered packages#45933
msyyc merged 1 commit intomainfrom
fix/namereserve-pypi-check

Conversation

@msyyc
Copy link
Copy Markdown
Member

@msyyc msyyc commented Mar 26, 2026

Issue

The daily name reservation pipeline (publish-namereserve-package.yml) fails to register new packages like azure-mgmt-appnetwork on PyPI because _is_on_pypi() in discover_unpublished_packages.py incorrectly 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 returned True — 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 result instead of assuming success when no exception is raised.

Validation

Tested locally:

  • azure-core (exists on PyPI) → correctly returns True
  • azure-mgmt-appnetwork (not on PyPI) → now correctly returns False
  • Full discovery run confirms azure-mgmt-appnetwork is now included in the registration list

Test for azure-mgmt-appnetwork and now it could be found: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6066615&view=results

…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.
Copilot AI review requested due to automatic review settings March 26, 2026 06:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@msyyc msyyc merged commit 4835c13 into main Mar 26, 2026
29 checks passed
@msyyc msyyc deleted the fix/namereserve-pypi-check branch March 26, 2026 07:25
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants