fix(config): handle invalid repository configurations gracefully - #11057
Open
CAOShurong wants to merge 1 commit into
Open
CAOShurong wants to merge 1 commit into
CAOShurong wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/poetry/utils/authenticator.py" line_range="403-405" />
<code_context>
self._configured_repositories = {}
for repository_name in self._config.get("repositories", []):
url = self._config.get(["repositories", repository_name, "url"])
+ if not isinstance(url, str):
+ logger.warning(
+ "Repository '%s' has an invalid url configured in settings;"
</code_context>
<issue_to_address>
**issue (bug_risk):** `configured_repositories` still raises `TypeError` before reaching the new URL check when the top-level `repositories` setting is `None`, a list, or another non-iterable/non-mapping value, because it iterates the raw setting directly. Such a malformed repository configuration still prevents commands from recovering.
**Triggers:** When `config.toml` contains a malformed top-level `repositories` value rather than a mapping.
**Suggested fix:** Read the setting with a mapping default and skip or warn when it is not a mapping before iterating its repository names.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: src/poetry/utils/authenticator.py:405
CAOShurong
force-pushed
the
fix-config-invalid-repo-url
branch
from
September 16, 2026 06:54
c20e604 to
5e1f9ac
Compare
Skip malformed top-level repository mappings and individual non-string URLs so recovery commands can continue instead of failing during configuration traversal or URL parsing. Guard direct repository-config construction, handle PoetryError while locating local config, and cover nested and top-level malformed cases. Fixes python-poetry#10570.
CAOShurong
force-pushed
the
fix-config-invalid-repo-url
branch
from
September 16, 2026 06:56
5e1f9ac to
87c580b
Compare
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.
Pull Request Check List
Resolves: #10570
When a repository in
config.tomlcontains an invalid or nested configuration, Poetry could fail while reading it before recovery commands such aspoetry config --unsetorpoetry config --listhad a chance to run. Invalid individual URLs could reachurllib.parse.urlsplit, while a malformed top-levelrepositoriesvalue such asnull, a list, or a scalar could fail even earlier during configuration traversal.Changes:
repositoriesvalue with a warning.AuthenticatorRepositoryConfigconstruction against a non-string URL.PoetryErrorwhile locating local project configuration sopoetry configcan still recover.Validation on exact head
87c580bc:git diff --checkpassed.AI assistance: OpenAI Codex assisted with the follow-up diagnosis, implementation, tests, and verification. The contributor reviewed and owns the submitted change.