{"record":{"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/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/argparsing.py#L342-L378","documentation":"Raised during addini() when an alias in the aliases= list collides with an existing ini option name already registered in the config. Aliases must not shadow canonical option names. The check `alias in self._inidict` fails.","triggerScenarios":"Calling parser.addini('new_opt', aliases=['old_opt']) where 'old_opt' was already registered via a prior addini call. The alias string matches a key already in self._inidict.","commonSituations":"Renaming an option and trying to alias the old name, but the old option is still registered by another plugin. Two plugins registering options with overlapping alias/name sets. Accidental alias collision with a built-in pytest option.","solutions":["Choose an alias that does not match any existing option name","Remove the conflicting addini call for the old name if it is no longer needed","Check registered options with config._parser._inidict keys before choosing aliases"],"exampleFix":"# before\nparser.addini('new_opt', type='string', aliases=['old_opt'])\n# ... elsewhere\nparser.addini('old_opt', type='string')\n\n# after\nparser.addini('new_opt', type='string', aliases=['legacy_opt'])\n# or remove the old registration","handlingStrategy":"validation","validationCode":"def check_alias_no_conflict(parser, aliases: list[str]) -> list[str]:\n    conflicts = [a for a in aliases if a in parser._inidict]\n    return conflicts\n# Usage: conflicts = check_alias_no_conflict(parser, ['old_name'])","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose aliases that do not match existing ini option names","Remove deprecated addini registrations before aliasing the old name","Inspect parser._inidict keys before registering aliases in plugins"],"tags":["pytest","config","addini","alias","naming-conflict","plugin-api"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}