{"record":{"id":"54f26ecc9fa18988","repo":"pypa/pip","slug":"dependency-groups-data-was-invalid-in-path","errorCode":null,"errorMessage":"[dependency-groups] data was invalid in {path}: {'; '.join(messages)}","messagePattern":"\\[dependency-groups\\] data was invalid in (.+?): (.+?)","errorType":"validation","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/req/req_dependency_group.py","lineNumber":65,"sourceCode":"        pyproject = _load_pyproject(path)\n        if \"dependency-groups\" not in pyproject:\n            raise InstallationError(\n                f\"[dependency-groups] table was missing from '{path}'. \"\n                \"Cannot resolve '--group' option.\"\n            )\n        raw_dependency_groups = pyproject[\"dependency-groups\"]\n        if not isinstance(raw_dependency_groups, dict):\n            raise InstallationError(\n                f\"[dependency-groups] table was malformed in {path}. \"\n                \"Cannot resolve '--group' option.\"\n            )\n\n        try:\n            resolvers[path] = DependencyGroupResolver(raw_dependency_groups)\n        except ExceptionGroup as eg:\n            # Handle ExceptionGroup from resolver initialization\n            messages = [str(e) for e in eg.exceptions]\n            raise InstallationError(\n                f\"[dependency-groups] data was invalid in {path}: {'; '.join(messages)}\"\n            ) from eg\n\n    return resolvers\n\n\ndef _load_pyproject(path: str) -> dict[str, Any]:\n    \"\"\"\n    This helper loads a pyproject.toml as TOML.\n\n    It raises an InstallationError if the operation fails.\n    \"\"\"\n    try:\n        with open(path, \"rb\") as fp:\n            return tomllib.load(fp)\n    except FileNotFoundError:\n        raise InstallationError(f\"{path} not found. Cannot resolve '--group' option.\")\n    except tomllib.TOMLDecodeError as e:","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/req/req_dependency_group.py#L47-L83","documentation":"The [dependency-groups] table exists and is a dict, but constructing a DependencyGroupResolver from it failed with an ExceptionGroup. This means individual entries within groups are malformed — not valid requirement strings and not valid include-group table objects. All sub-error messages are collected and reported.","triggerScenarios":"A group contains a non-string, non-table entry such as 'mygroup = [123]' or 'mygroup = [{ include-group = 123 }]' (include-group value must be a string). The resolver rejects these during initialization.","commonSituations":"Numeric or boolean values where strings are expected. include-group pointing to a number instead of a string name. Mismatched schema after a TOML editing mistake.","solutions":["Read each sub-message in the error to find which specific entry is invalid","Ensure every list entry is either a valid PEP 508 requirement string or a table like { include-group = \"other-group\" }","Validate entries programmatically before relying on pip"],"exampleFix":"# before — pyproject.toml\n[dependency-groups]\ntest = [123]\n\n# after\n[dependency-groups]\ntest = [\"pytest\"]","handlingStrategy":"validation","validationCode":"from pip._vendor.packaging.dependency_groups import DependencyGroupResolver\nfrom pip._vendor.packaging.errors import ExceptionGroup\n\ndef validate_dependency_groups_data(path: str) -> list[str]:\n    \"\"\"Returns list of error messages; empty if valid.\"\"\"\n    from pip._internal.utils.compat import tomllib\n    with open(path, \"rb\") as fp:\n        data = tomllib.load(fp)\n    raw = data.get(\"dependency-groups\", {})\n    try:\n        DependencyGroupResolver(raw)\n        return []\n    except ExceptionGroup as eg:\n        return [str(e) for e in eg.exceptions]","typeGuard":"from pip._vendor.packaging.dependency_groups import DependencyGroupResolver\n\ndef is_valid_dependency_groups_data(raw: dict) -> bool:\n    \"\"\"Type guard: True if DependencyGroupResolver accepts the data.\"\"\"\n    try:\n        DependencyGroupResolver(raw)\n        return True\n    except Exception:\n        return False","tryCatchPattern":"from pip._internal.exceptions import InstallationError\nfrom pip._internal.req.req_dependency_group import parse_dependency_groups\n\ntry:\n    reqs = parse_dependency_groups([(\"pyproject.toml\", \"dev\")])\nexcept InstallationError as e:\n    if \"data was invalid\" in str(e):\n        print(\"Fix malformed entries in [dependency-groups]\")\n    else:\n        raise","preventionTips":["Ensure every entry is a valid PEP 508 string or an {include-group = \"...\"} table","Validate with DependencyGroupResolver() in a pre-commit hook","Avoid numeric or boolean values in group requirement lists"],"tags":["pip","dependency-groups","pep735","validation","configuration"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}