python-poetry/poetry · error · ValueError

Setting {self.argument('key')} does not exist

Error message

Setting {self.argument('key')} does not exist

What it means

Fallback ValueError raised at config.py:367 when the config key matches none of the recognized patterns (`repositories.*`, `http-basic.*`, `pypi-token.*`, `certificates.*`, `installer.build-config-settings.*`) and is not in `unique_config_values`. It signals the user mistyped or invented a setting name.

Source

Thrown at src/poetry/console/commands/config.py:367

            except PropertyNotFoundError:
                settings = {}

            for value in values:
                if build_config_setting_validator(value):
                    config_settings = build_config_setting_normalizer(value)
                    for setting_name, item in config_settings.items():
                        settings[setting_name] = item
                else:
                    raise ValueError(
                        f"Invalid build config setting '{value}'. "
                        "It must be a valid JSON with each property a string or a list of strings."
                    )

            config.config_source.add_property(key, settings)

            return 0

        raise ValueError(f"Setting {self.argument('key')} does not exist")

    def _handle_single_value(
        self,
        source: ConfigSource,
        key: str,
        callbacks: tuple[Any, Any],
        values: list[Any],
    ) -> int:
        validator, normalizer = callbacks

        if len(values) > 1:
            raise RuntimeError("You can only pass one value.")

        value = values[0]
        if not validator(value):
            raise RuntimeError(f'"{value}" is an invalid value for {key}')

        source.add_property(key, normalizer(value))

View on GitHub (pinned to 92b74dcfe3)

Solutions

  1. List valid settings with `poetry config --list` and copy the exact key.
  2. Check the key against `unique_config_values` and the regex branches in `ConfigCommand.handle`.
  3. For repositories, use the `repositories.<name>.url` form.

Example fix

# before
poetry config virtualenv.in-project true
# after
poetry config virtualenvs.in-project true
Defensive patterns

Strategy: validation

Validate before calling

import re
from poetry.console.commands.config import ConfigCommand
KEY = "virtualenvs.in-project"
cmd = ConfigCommand()
known = set(cmd.unique_config_values)
patterns = [r"repositories\..+", r"http-basic\..+", r"pypi-token\..+",
            r"certificates\..+\.(cert|client-cert)$",
            r"installer\.build-config-settings\.[^.]+"]
assert KEY in known or any(re.match(p, KEY) for p in patterns), f"unknown setting {KEY}"

Type guard

def is_known_config_key(key: str) -> bool:
    import re
    patterns = [r"repositories\..+", r"http-basic\..+", r"pypi-token\..+",
                r"certificates\..+\.(cert|client-cert)$",
                r"installer\.build-config-settings\.[^.]+"]
    return key in known_keys or any(re.match(p, key) for p in patterns)

Prevention

When it happens

Trigger: Running `poetry config typo.key value`, or `poetry config installer.max-workers` (note the dash vs the actual `installer.max-workers` may exist; any unknown root raises). Any key not enumerated in `unique_config_values` (config.py:78-101) and not matching a regex branch falls through.

Common situations: Typing a setting name from memory; using a setting removed in a newer Poetry version; mixing dashes and underscores.

Related errors


AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04). Data as JSON: /data/errors/b280787f1c2143c3.json. Report an issue: GitHub.