{"record":{"id":"cb2703f7872a85c2","repo":"pytest-dev/pytest","slug":"unknown-configuration-value-name-r","errorCode":null,"errorMessage":"unknown configuration value: {name!r}","messagePattern":"unknown configuration value: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/__init__.py","lineNumber":1806,"sourceCode":"        self._inicache[canonical_name] = val = self._getini(canonical_name)\n        return val\n\n    # Meant for easy monkeypatching by legacypath plugin.\n    # Can be inlined back (with no cover removed) once legacypath is gone.\n    def _getini_unknown_type(self, name: str, type: str, value: object):\n        msg = (\n            f\"Option {name} has unknown configuration type {type} with value {value!r}\"\n        )\n        raise ValueError(msg)  # pragma: no cover\n\n    def _getini(self, name: str):\n        # If this is an alias, resolve to canonical name.\n        canonical_name = self._parser._ini_aliases.get(name, name)\n\n        try:\n            _description, type, default = self._parser._inidict[canonical_name]\n        except KeyError as e:\n            raise ValueError(f\"unknown configuration value: {name!r}\") from e\n\n        # Collect all possible values (canonical name + aliases) from _inicfg.\n        # Each candidate is (ConfigValue, is_canonical).\n        candidates = []\n        if canonical_name in self._inicfg:\n            candidates.append((self._inicfg[canonical_name], True))\n        for alias, target in self._parser._ini_aliases.items():\n            if target == canonical_name and alias in self._inicfg:\n                candidates.append((self._inicfg[alias], False))\n\n        if not candidates:\n            return default\n\n        # Pick the best candidate based on precedence:\n        # 1. CLI override takes precedence over file, then\n        # 2. Canonical name takes precedence over alias.\n        selected = max(candidates, key=lambda x: (x[0].origin == \"override\", x[1]))[0]\n        value = selected.value","sourceCodeStart":1788,"sourceCodeEnd":1824,"githubUrl":"https://github.com/pytest-dev/pytest/blob/0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc/src/_pytest/config/__init__.py#L1788-L1824","documentation":"Raised by Config._getini() (src/_pytest/config/__init__.py:1806) when getini(name) is called for a name that is neither registered by an addini() call nor an alias. _parser._inidict is keyed by canonical names (config/__init__.py:1804); the KeyError at capture.py:1805 is re-raised as ValueError. This is an internal API error - external code rarely calls _getini directly.","triggerScenarios":"A plugin or test calling config.getini('typo_option') where no plugin has invoked parser.addini('typo_option', ...). The lookup at config/__init__.py:1804 raises KeyError and capture.py:1805-1806 wraps it.","commonSituations":"Typos in plugin code that reads its own ini option; calling getini before pytest_addoption has registered it; renaming an ini option without updating all call sites; a third-party plugin removed/renamed an option your conftest reads.","solutions":["Register the option first: call parser.addini(name, ...) in a pytest_addoption hook","Check the spelling of the option name against the plugin's documentation/source","If the option is from a plugin, ensure that plugin is actually enabled and its pytest_addoption ran","Guard with `if name in config._parser._inidict:` before calling getini"],"exampleFix":"// before\nvalue = config.getini('my_opt')\n# nothing registered my_opt\n// after\ndef pytest_addoption(parser):\n    parser.addini('my_opt', help='...', default='x')\nvalue = config.getini('my_opt')","handlingStrategy":"validation","validationCode":"def ini_registered(config, name: str) -> bool:\n    canonical = config._parser._ini_aliases.get(name, name)\n    return canonical in config._parser._inidict","typeGuard":"def ini_known(config, name: str) -> bool:\n    return name in config._parser._inidict or name in config._parser._ini_aliases","tryCatchPattern":"try:\n    val = config.getini(name)\nexcept ValueError:\n    val = default","preventionTips":["Register every ini option your plugin reads via parser.addini in pytest_addoption","Cross-check option names against _parser._inidict keys when debugging","Add unit tests that exercise getini for each option your plugin declares"],"tags":["config","ini","api-misuse","plugin"],"backgroundTag":null,"analyzedSha":"0d6fbdeffa57c796123f62f81f7dd370d9b7ecdc","analyzedAt":"2026-08-11T20:52:36.969Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}