{"id":"2f0bf87ff36a1576","repo":"python-poetry/poetry","slug":"expected-one-or-two-arguments-username-password","errorCode":null,"errorMessage":"Expected one or two arguments (username, password), got {len(values)}","messagePattern":"Expected one or two arguments \\(username, password\\), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/poetry/console/commands/config.py","lineNumber":290,"sourceCode":"            from poetry.utils.password_manager import PasswordManager\n\n            password_manager = PasswordManager(config)\n            if self.option(\"unset\"):\n                if m.group(1) == \"http-basic\":\n                    password_manager.delete_http_password(m.group(2))\n                elif m.group(1) == \"pypi-token\":\n                    password_manager.delete_pypi_token(m.group(2))\n\n                return 0\n\n            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","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/console/commands/config.py#L272-L308","documentation":"Raises ValueError in ConfigCommand.handle() when setting http-basic credentials with neither 1 nor 2 value arguments. With 1 value, Poetry treats it as username and prompts for the password interactively; with 2 values, it takes (username, password). Zero or 3+ values is invalid. The check at line 289-293 fires in the elif after the len==1 case.","triggerScenarios":"Running `poetry config http-basic.pypi` (zero values, which hits this path because the prohibited-settings check at line 167 only fires when no value is given AND key starts with 'http-basic' — but the value argument is multiple=True so empty list has falsy len). Or running with 3+ values like `poetry config http-basic.pypi user pass extra`.","commonSituations":"User omits both username and password expecting an interactive prompt that doesn't trigger (the 1-value prompt path requires exactly 1 arg), or passes extra stray arguments.","solutions":["Provide exactly 1 value (username, then you'll be prompted for password) or 2 values (username password): `poetry config http-basic.pypi myuser mypass`.","If you want the interactive prompt, pass just the username: `poetry config http-basic.pypi myuser`."],"exampleFix":"# before (error)\npoetry config http-basic.pypi myuser mypass extra\n# after\npoetry config http-basic.pypi myuser mypass","handlingStrategy":"validation","validationCode":"def validate_http_basic(values: list[str]) -> None:\n    if len(values) not in (1, 2):\n        raise ValueError(\n            f\"Expected 1 (username) or 2 (username, password) arguments, got {len(values)}\"\n        )","typeGuard":"def is_valid_http_basic(values: list[str]) -> bool:\n    return len(values) in (1, 2)","tryCatchPattern":null,"preventionTips":["Pass 1 value (username) to be prompted for password, or 2 values (username password).","Avoid extra arguments beyond username and password.","Use 'poetry config http-basic.REPO USERNAME' for interactive password entry."],"tags":["config-command","valueerror","http-basic","auth","wrong-arg-count","cli-validation"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}