{"id":"3cfde3b705d71063","repo":"pytest-dev/pytest","slug":"alias-alias-r-conflicts-with-existing-configurat","errorCode":null,"errorMessage":"alias {alias!r} conflicts with existing configuration option","messagePattern":"alias (.+?) conflicts with existing configuration option","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/argparsing.py","lineNumber":360,"sourceCode":"            ini_type = tuple(\n                _ini_type_to_member(name, member) for member in get_args(type)\n            )\n        else:\n            ini_type = _ini_type_to_member(name, type)\n        if default is NOTSET:\n            if isinstance(ini_type, (tuple, _IniLiteral)):\n                kind = \"union\" if isinstance(ini_type, tuple) else \"Literal\"\n                raise ValueError(\n                    f\"ini option {name!r} has a {kind} type, which has no \"\n                    \"implicit default; pass an explicit `default` to `addini`\"\n                )\n            default = get_ini_default_for_type(ini_type)\n\n        self._inidict[name] = (help, ini_type, default)\n\n        for alias in aliases:\n            if alias in self._inidict:\n                raise ValueError(\n                    f\"alias {alias!r} conflicts with existing configuration option\"\n                )\n            if (already := self._ini_aliases.get(alias)) is not None:\n                raise ValueError(f\"{alias!r} is already an alias of {already!r}\")\n            self._ini_aliases[alias] = name\n\n\ndef get_ini_default_for_type(type: _IniTypeTag) -> Any:\n    \"\"\"\n    Used by addini to get the default value for a given config option type, when\n    default is not supplied.\n    \"\"\"\n    if type in (\"paths\", \"pathlist\", \"args\", \"linelist\"):\n        return []\n    elif type == \"bool\":\n        return False\n    elif type == \"int\":\n        return 0","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/argparsing.py#L342-L378","documentation":"Raised by Parser.addini() when an alias passed via the aliases= parameter collides with an already-registered ini option name. Aliases must not shadow canonical option names. This is a registration-time ValueError surfaced during plugin/conftest loading.","triggerScenarios":"Calling parser.addini('foo', ..., aliases=['bar']) when 'bar' was already added as a canonical ini option by an earlier addini call. The check at line 359 finds alias in self._inidict.","commonSituations":"Two plugins where one's alias matches another's option name; renaming an option and adding the old name as an alias while another plugin already registered that name; typos causing accidental collisions.","solutions":["Rename the alias to something not already registered as an ini option.","Reorder addini calls so the alias does not collide, or remove the conflicting registration.","Check existing ini options via `pytest --help` or config._parser._inidict when debugging plugin load order."],"exampleFix":"# before\nparser.addini('bar', help='...')\nparser.addini('foo', aliases=['bar'], help='...')  # collides\n\n# after\nparser.addini('foo', aliases=['foo_alt'], help='...')","handlingStrategy":"validation","validationCode":"def check_alias_not_an_option(parser_inidict: dict, alias: str) -> None:\n    if alias in parser_inidict:\n        raise ValueError(f'alias {alias!r} conflicts with existing configuration option')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Namespace aliases with a plugin prefix to avoid collisions.","Document all registered ini options and aliases in your plugin README."],"tags":["pytest","plugin","config","addini","alias","naming-conflict"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}