Repository navigation
fix(authenticator): handle missing URL in repository config - #11081
Conversation
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the new bytes-to-text normalization or path matching is wrong, a bytes URL could select the wrong repository configuration and cause credentials or certificate settings to be applied to an unintended endpoint. Reverting stops future misrouting, but any credentials already sent to that endpoint cannot be recovered.
34b7f7b to
1db8d0b
Compare
kokokoXUY
left a comment
There was a problem hiding this comment.
The confirmed #11080 reproducer is an empty [repositories.company-internal] section with no url, so Config.get(..., "url") returns None rather than a bytes URL. urlsplit(None) produces a byte-valued result with path=b''; this PR's _path_segments() now decodes that empty path, allowing AuthenticatorRepositoryConfig to be constructed with url=None and byte-valued scheme, netloc, and path. The startup exception disappears, but the invalid repository entry remains silently present instead of producing the clear configuration error requested in the issue.
Could you add a regression test with a repository section missing url and reject it with a descriptive error at the configuration boundary? The bytes-input support can be considered separately if there is a supported path that produces bytes URLs.
|
Follow-up to my earlier review, with a correction: I have since verified that $ poetry config repositories.company-internal https://company-internal.host
The repository 'company-internal' is missing a url. Please set it with `poetry config repositories.company-internal <url>`.
$ echo $?
1So rejecting the entry at the configuration boundary would leave users unable For this PR, a regression test that uses the reproducer from the issue (an |
|
Hi @kokokoXUY, thank you for the detailed analysis and follow-up! I have implemented the requested reproducer regression test in commit 36862ac:
All changes signed off and pushed to the PR branch. |
|
As per #11080 (comment) this may not be the desired fix:
The type hint of |
|
Hi @radoering, Thank you for the guidance! I agree that preserving the I have updated the implementation in commit
All unit tests are passing and changes have been pushed to this PR branch. |
radoering
left a comment
There was a problem hiding this comment.
I do not think we have to handle bytes because they only resulted from an empty URL. See #11080 (comment)
|
Hi @radoering, Thank you! You are completely right — the In commit
All unit tests pass cleanly. |
Linked issuesChecked at commit 618a563 #11080 Poetry 2.5.0/2.5.1 TypeError str instead of bytes-like object · 1 of 1 met
|
In Poetry 2.5, `AuthenticatorRepositoryConfig` computes path segments via
`_path_segments(self.path)` where `self.path` is extracted from
`urllib.parse.urlsplit(self.url)`. If `self.url` or a candidate request URL
is passed as `bytes`, `urlsplit` returns `SplitResultBytes` where `path` is
also `bytes`, causing `path.split("/")` to raise `TypeError: a bytes-like
object is required, not 'str'`.
Fix this by ensuring `self.url` is decoded to `str` in `__post_init__`,
and having `_path_segments`, `path_match_key`, and
`_get_repository_config_for_url` decode `bytes` inputs to `str` before
segment splitting and parsing.
Added regression tests in `tests/utils/test_authenticator.py` covering
bytes URLs, bytes paths, and whole-path repository matching.
Fixes python-poetry#11080
Signed-off-by: Samran Asif <[email protected]>
AI-assisted contribution — logic and code authored with LLM support,
reviewed and verified by Samran Asif (webdevsamran).
…test (python-poetry#11080) Signed-off-by: Samran Asif <[email protected]>
…None Signed-off-by: Samran Asif <[email protected]>
…ython-poetry#11080) Signed-off-by: Samran Asif <[email protected]>
…on-poetry#11080) Signed-off-by: Samran Asif <[email protected]>
de59ab2 to
618a563
Compare
(cherry picked from commit 86093b2)
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [poetry](https://github.com/python-poetry/poetry) ([changelog](https://python-poetry.org/history/)) | patch | `2.5.1` → `2.5.2` | --- ### Release Notes <details> <summary>python-poetry/poetry (poetry)</summary> ### [`v2.5.2`](https://github.com/python-poetry/poetry/blob/HEAD/CHANGELOG.md#252---2026-11-21) [Compare Source](python-poetry/poetry@2.5.1...2.5.2) ##### Changed - Allow `pkginfo>=2.0` ([#​11239](python-poetry/poetry#11239)). - Report a comprehensible error if a configured repository is missing a URL ([#​11081](python-poetry/poetry#11081), [#​11114](python-poetry/poetry#11114), [#​11242](python-poetry/poetry#11242)). - Report a comprehensible error for an invalid `--priority` in `poetry source add` instead of failing with a `KeyError` ([#​11175](python-poetry/poetry#11175)). ##### Fixed - Fix an issue where `poetry install` built an sdist before checking it against its lock file hash ([#​11253](python-poetry/poetry#11253)). - Fix an issue where `poetry install` rejected a distribution even though one of the hashes provided by the package index matched the hash locked for that file. ([#​11131](python-poetry/poetry#11131)). - Fix an issue where uninstalling a path dependency failed if its source did not exist anymore ([#​11093](python-poetry/poetry#11093)). - Fix an issue where `poetry version prerelease` failed for a dev release ([#​11217](python-poetry/poetry#11217)). ##### Docs - Document the options of `poetry debug resolve` ([#​11211](python-poetry/poetry#11211)). - Clarify `solver.min-release-age-exclude` and `solver.min-release-age-exclude-source` ([#​11087](python-poetry/poetry#11087)). - Distinguish package and upload repository URLs ([#​11143](python-poetry/poetry#11143)). - Explain the certificate configuration for system Git ([#​11145](python-poetry/poetry#11145)). - Add separate directory and archive path dependency examples ([#​11079](python-poetry/poetry#11079)). - Use the plugin repository for the `poetry-export` pre-commit hook ([#​11213](python-poetry/poetry#11213)). - Fix the incorrect `tool.poetry` section name in the FAQ ([#​11150](python-poetry/poetry#11150)). </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNjAuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI2MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://git.walbeck.it/mwalbeck/docker-python-poetry/pulls/1778
Pull Request Check List
Resolves: #11080
Description
In Poetry 2.5,
AuthenticatorRepositoryConfigcomputes path segments via_path_segments(self.path)whereself.pathis extracted fromurllib.parse.urlsplit(self.url).If
self.urlor a candidate request URL is passed asbytes(e.g. from environment sources, credentials, or custom plugin hooks),urlsplitreturns aSplitResultByteswherepathis alsobytes. Passing abytespath to_path_segmentscausespath.split("/")to raise:Solution
AuthenticatorRepositoryConfig.__post_init__, decodeself.urltostrif it is an instance ofbytes._path_segmentsandpath_match_key, acceptstr | bytesand decodebytesbefore segment extraction._get_repository_config_for_url, decodeurlif it isbytesbefore URL parsing.Verification
Added regression tests in
tests/utils/test_authenticator.pycovering:AuthenticatorRepositoryConfigwithbytesURL andbytesrequest paths._path_segmentswithbytesinputs.Authenticator.get_repository_config_for_urlwithbytesURL.Ran the full authenticator test suite (
78 passed in 6.40s) and verified formatting withruff.🤖 AI-assisted contribution — logic and code authored with LLM support, reviewed and verified by Samran Asif (@webdevsamran).