{"record":{"id":"5110c3c458b5094d","repo":"pypa/pip","slug":"fatal-internal-error-id-2-please-report-as-a-bu","errorCode":null,"errorMessage":"Fatal Internal error [id=2]. Please report as a bug.","messagePattern":"Fatal Internal error \\[id=2\\]\\. Please report as a bug\\.","errorType":"exception","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/configuration.py","lineNumber":381,"sourceCode":"        # virtualenv config\n        yield kinds.SITE, config_files[kinds.SITE]\n\n        if env_config_file is not None:\n            yield kinds.ENV, [env_config_file]\n        else:\n            yield kinds.ENV, []\n\n    def get_values_in_config(self, variant: Kind) -> dict[str, Any]:\n        \"\"\"Get values present in a config file\"\"\"\n        return self._config[variant]\n\n    def _get_parser_to_modify(self) -> tuple[str, RawConfigParser]:\n        # Determine which parser to modify\n        assert self.load_only\n        parsers = self._parsers[self.load_only]\n        if not parsers:\n            # This should not happen if everything works correctly.\n            raise ConfigurationError(\n                \"Fatal Internal error [id=2]. Please report as a bug.\"\n            )\n\n        # Use the highest priority parser.\n        return parsers[-1]\n\n    # XXX: This is patched in the tests.\n    def _mark_as_modified(self, fname: str, parser: RawConfigParser) -> None:\n        file_parser_tuple = (fname, parser)\n        if file_parser_tuple not in self._modified_parsers:\n            self._modified_parsers.append(file_parser_tuple)\n\n    def __repr__(self) -> str:\n        return f\"{self.__class__.__name__}({self._dictionary!r})\"\n","sourceCodeStart":363,"sourceCodeEnd":396,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/configuration.py#L363-L396","documentation":"Raised by Configuration._get_parser_to_modify() when the list of parsers for the selected load_only layer is empty. This means pip was asked to edit a configuration layer (e.g. --site) but no config file for that layer was ever loaded/parsed — there is no file object to write to. pip treats this as an internal inconsistency because the load path should always populate at least one parser entry.","triggerScenarios":"A genuine internal inconsistency: load_only is set, but _load_config_files did not register any parser for that variant. Practically unreachable without a bug in the load logic, a failed/patched _load_file, or a race that clears the _parsers list.","commonSituations":"Extremely rare; could surface with custom test patches of iter_config_files or _load_file, or version skew in embedded pip usage. Most end users never encounter it.","solutions":["Report as a bug to pip with the command, version, and config file layout (https://github.com/pypa/pip/issues).","Ensure the target config file for the selected scope actually exists or is creatable (check home directory and sys.prefix writability).","Retry with a different scope (--user vs --global) to see if the issue is layer-specific.","Restart the interpreter/shell to rule out stale patched state."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from pip._internal.exceptions import ConfigurationError\ntry:\n    cfg.set_value(key, value)\nexcept ConfigurationError as e:\n    if 'Fatal Internal error [id=2]' in str(e):\n        # reload config files, then retry once\n        cfg.load()\n        cfg.set_value(key, value)\n    else:\n        raise\n","preventionTips":["Report occurrences — this is labeled an internal bug.","Ensure the target config layer's files are accessible before editing."],"tags":["pip","config","internal","bug"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}