{"id":"80d598720b9a7643","repo":"pypa/pip","slug":"got-invalid-value-for-load-only-should-be-one-of","errorCode":null,"errorMessage":"Got invalid value for load_only - should be one of {}","messagePattern":"Got invalid value for load_only - should be one of (.+?)","errorType":"exception","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/configuration.py","lineNumber":106,"sourceCode":"class Configuration:\n    \"\"\"Handles management of configuration.\n\n    Provides an interface to accessing and managing configuration files.\n\n    This class converts provides an API that takes \"section.key-name\" style\n    keys and stores the value associated with it as \"key-name\" under the\n    section \"section\".\n\n    This allows for a clean interface wherein the both the section and the\n    key-name are preserved in an easy to manage form in the configuration files\n    and the data stored is also nice.\n    \"\"\"\n\n    def __init__(self, isolated: bool, load_only: Kind | None = None) -> None:\n        super().__init__()\n\n        if load_only is not None and load_only not in VALID_LOAD_ONLY:\n            raise ConfigurationError(\n                \"Got invalid value for load_only - should be one of {}\".format(\n                    \", \".join(map(repr, VALID_LOAD_ONLY))\n                )\n            )\n        self.isolated = isolated\n        self.load_only = load_only\n\n        # Because we keep track of where we got the data from\n        self._parsers: dict[Kind, list[tuple[str, RawConfigParser]]] = {\n            variant: [] for variant in OVERRIDE_ORDER\n        }\n        self._config: dict[Kind, dict[str, dict[str, Any]]] = {\n            variant: {} for variant in OVERRIDE_ORDER\n        }\n        self._modified_parsers: list[tuple[str, RawConfigParser]] = []\n\n    def load(self) -> None:\n        \"\"\"Loads configuration from configuration files and environment\"\"\"","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/configuration.py#L88-L124","documentation":"Raised as ConfigurationError in Configuration.__init__ at configuration.py:105-110 when load_only is not None and not in VALID_LOAD_ONLY (USER, GLOBAL, SITE). The Configuration object accepts loading a single variant only, and any other string (typos, internal kinds like 'env' or 'env-var') is rejected at construction time.","triggerScenarios":"Programmatically constructing Configuration(isolated=..., load_only='something') with a value outside {'user','global','site'} — e.g. load_only='env', load_only='environment', or a typo like 'userr'. The check at configuration.py:105 compares against VALID_LOAD_ONLY defined at configuration.py:46.","commonSituations":"Internal/tooling code that builds a Configuration directly with the wrong variant name; passing the PIP_CONFIG_FILE-based 'env' kind as load_only; typos in wrapper scripts.","solutions":["Use one of the three valid load_only values: 'user', 'global', or 'site'.","Pass load_only=None if you want to load all variants.","Check the VALID_LOAD_ONLY tuple / kinds enum in configuration.py for the canonical strings."],"exampleFix":"# before\nfrom pip._internal.configuration import Configuration\ncfg = Configuration(isolated=False, load_only='environment')  # invalid\n# after\ncfg = Configuration(isolated=False, load_only='user')","handlingStrategy":"type-guard","validationCode":"from pip._internal.configuration import VALID_LOAD_ONLY\n\ndef make_config(isolated: bool, load_only):\n    if load_only is not None and load_only not in VALID_LOAD_ONLY:\n        raise ValueError(f'load_only must be one of {VALID_LOAD_ONLY} or None')\n    from pip._internal.configuration import Configuration\n    return Configuration(isolated=isolated, load_only=load_only)","typeGuard":"from pip._internal.configuration import VALID_LOAD_ONLY\n\ndef is_valid_load_only(value) -> bool:\n    return value is None or value in VALID_LOAD_ONLY","tryCatchPattern":null,"preventionTips":["Only pass 'user', 'global', or 'site' (or None) as load_only.","Validate against VALID_LOAD_ONLY before constructing a Configuration.","Prefer the 'pip config' CLI which handles load_only selection for you."],"tags":["pip","config","configuration","invalid-argument","internal-api"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}