fix(publish): normalize legacy repository URL trailing slash (#6687)#10785
Merged
radoering merged 3 commits intopython-poetry:mainfrom Mar 28, 2026
Merged
Conversation
…poetry#6687) - Simplify _normalize_legacy_repository_url per maintainer suggestion - Fix broken call_args assertions in test, use assert_called_once_with - Add parametrized test cases: already-normalized URL and non-legacy URL
Reviewer's GuideNormalizes legacy repository URLs before publishing so missing trailing slashes on /legacy endpoints are handled correctly, and adds focused tests that verify URL normalization and correct uploader calls. Sequence diagram for publishing with normalized legacy repository URLsequenceDiagram
actor User
participant Publisher
participant PoetryConfig as Poetry_config
participant Normalizer as _normalize_legacy_repository_url
participant Uploader
User->>Publisher: publish(repository_name, username, password, ...)
Publisher->>PoetryConfig: get(repositories.{repository_name}.url)
PoetryConfig-->>Publisher: url
Publisher->>Normalizer: _normalize_legacy_repository_url(url)
Normalizer-->>Publisher: normalized_url
Publisher->>Uploader: upload(normalized_url, credentials, artifacts)
Uploader-->>Publisher: result
Publisher-->>User: publish_result
Updated class diagram for Publisher and legacy URL normalizationclassDiagram
class Publisher {
- poetry
- http_session
+ publish(repository_name, username, password, dry_run, cert, client_cert)
}
class _normalize_legacy_repository_url {
+ _normalize_legacy_repository_url(url str) str
}
class PoetryConfig {
+ get(key str) str
}
class Uploader {
+ upload(url str, username str, password str, artifacts list)
}
Publisher --> PoetryConfig : uses
Publisher --> Uploader : uses
Publisher --> _normalize_legacy_repository_url : calls
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Documentation Updates 1 document(s) were updated by changes in this PR: configurationView Changes@@ -564,6 +564,10 @@
See [Publishable Repositories]({{< relref "repositories#publishable-repositories" >}}) for more information.
+{{% note %}}
+Poetry automatically normalizes legacy repository URLs by adding a trailing slash if one is missing. This means both `https://test.pypi.org/legacy` and `https://test.pypi.org/legacy/` will work correctly when publishing.
+{{% /note %}}
+
### `http-basic.<name>.[username|password]`
**Type**: `string` |
Contributor
Author
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
Deploy preview for website ready! ✅ Preview Built with commit 941a9c2. |
radoering
approved these changes
Mar 28, 2026
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.
Fixes #6687
When a PEP 503 legacy repository is configured without a trailing slash
(e.g.
https://test.pypi.org/legacy), uploads silently fail because theserver expects the
/legacy/path.This PR normalizes the URL before publishing.
Changes:
_normalize_legacy_repository_urlto a one-liner per@radoering's suggestion in fix(publish): normalize legacy repository URL trailing slash #10732 (removes urllib.parse import)
call_argsassertions in test — replaced withassert_called_once_withwhich actually validates the callNote: This supersedes #10732 which had reviewer feedback pending.
Summary by Sourcery
Normalize configured legacy repository URLs during publishing to ensure uploads target the correct endpoint.
Bug Fixes:
Tests: