{"id":"c62b73b597e81c27","repo":"python-poetry/poetry","slug":"expected-only-one-argument-token-got-len-value","errorCode":null,"errorMessage":"Expected only one argument (token), got {len(values)}","messagePattern":"Expected only one argument \\(token\\), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/poetry/console/commands/config.py","lineNumber":301,"sourceCode":"            if m.group(1) == \"http-basic\":\n                if len(values) == 1:\n                    username = values[0]\n                    # Only username, so we prompt for password\n                    password = self.secret(\"Password:\")\n                    assert isinstance(password, str)\n                elif len(values) != 2:\n                    raise ValueError(\n                        \"Expected one or two arguments \"\n                        f\"(username, password), got {len(values)}\"\n                    )\n                else:\n                    username = values[0]\n                    password = values[1]\n\n                password_manager.set_http_password(m.group(2), username, password)\n            elif m.group(1) == \"pypi-token\":\n                if len(values) != 1:\n                    raise ValueError(\n                        f\"Expected only one argument (token), got {len(values)}\"\n                    )\n\n                token = values[0]\n\n                password_manager.set_pypi_token(m.group(2), token)\n\n            return 0\n\n        # handle certs\n        m = re.match(r\"certificates\\.(.+)\\.(cert|client-cert)$\", self.argument(\"key\"))\n        if m:\n            repository = m.group(1)\n            key = m.group(2)\n\n            if self.option(\"unset\"):\n                config.auth_config_source.remove_property(\n                    [\"certificates\", repository, key]","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/console/commands/config.py#L283-L319","documentation":"Raises ValueError in ConfigCommand.handle() when setting a PyPI token with a number of values other than exactly 1. A token is a single string; providing zero or 2+ values is invalid. The check at line 300-303 fires inside the pypi-token branch of the auth-handling section.","triggerScenarios":"Running `poetry config pypi-token.pypi token1 token2` (2 values) — len(values) != 1. Note: zero values would hit the LIST_PROHIBITED_SETTINGS check (error 12) first.","commonSituations":"User passes multiple tokens by mistake, or includes extra arguments after the token value.","solutions":["Provide exactly one token string: `poetry config pypi-token.pypi pypi-AgEIcHl...`."],"exampleFix":"# before (error)\npoetry config pypi-token.pypi token-one token-two\n# after\npoetry config pypi-token.pypi pypi-AgEIcHl...","handlingStrategy":"validation","validationCode":"def validate_pypi_token(values: list[str]) -> None:\n    if len(values) != 1:\n        raise ValueError(f\"Expected exactly 1 token argument, got {len(values)}\")","typeGuard":"def is_valid_pypi_token(values: list[str]) -> bool:\n    return len(values) == 1","tryCatchPattern":null,"preventionTips":["Pass exactly one token string when configuring a PyPI token.","Avoid extra arguments after the token.","Quote the token if it contains shell-special characters."],"tags":["config-command","valueerror","pypi-token","auth","wrong-arg-count","cli-validation"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}