{"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":"exception","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/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/req/req_dependency_group.py#L47-L83","documentation":"Raised by _build_resolvers() when constructing the DependencyGroupResolver from the [dependency-groups] data raises an ExceptionGroup (req_dependency_group.py:62-67). Unlike error 136 (which fires during resolution of a specific group), this fires during RESOLVER INITIALIZATION — meaning the table structure is malformed in a way the resolver rejects up front (e.g. a group value that is not a list, or contains non-string elements).","triggerScenarios":"A [dependency-groups] table where a group's value is not a list, e.g. `dev = \"pytest\"` or `dev = {x=1}`, or a list containing non-string entries. DependencyGroupResolver(raw_dependency_groups) raises an ExceptionGroup during validation; pip joins the sub-exception messages.","commonSituations":"Hand-authoring groups with the wrong value type. Tooling that serializes a dict-of-dicts instead of dict-of-lists. Mixing TOML types accidentally.","solutions":["Ensure each group's value is a TOML array of PEP 508 requirement strings (or `{other-group}` references).","Read the joined messages to find the specific malformed group and fix its value type.","Validate by loading the file and checking `isinstance(data['dependency-groups'][name], list)` for each group.","Re-run pip after correcting the structure."],"exampleFix":"# before\n[dependency-groups]\ndev = \"pytest\"\n# after\n[dependency-groups]\ndev = [\"pytest\"]","handlingStrategy":"validation","validationCode":"import tomllib\nfrom pip._vendor.packaging.dependency_groups import DependencyGroupResolver\nfrom pip._vendor.packaging.errors import ExceptionGroup\n\ndef validate_dependency_groups_init(path: str) -> None:\n    with open(path, \"rb\") as f:\n        data = tomllib.load(f)\n    raw = data.get(\"dependency-groups\", {})\n    if not isinstance(raw, dict):\n        raise TypeError(\"dependency-groups must be a dict of group -> list[str]\")\n    for name, val in raw.items():\n        if not isinstance(val, list) or not all(isinstance(i, str) for i in val):\n            raise TypeError(f\"group {name!r} must be a list of strings\")\n    try:\n        DependencyGroupResolver(raw)\n    except ExceptionGroup as eg:\n        raise ValueError(\"; \".join(str(e) for e in eg.exceptions)) from eg","typeGuard":"def is_group_value_list_of_str(val) -> bool:\n    return isinstance(val, list) and all(isinstance(i, str) for i in val)","tryCatchPattern":"from pip._internal.exceptions import InstallationError\n\ntry:\n    parse_dependency_groups([(path, group)])\nexcept InstallationError as e:\n    if \"data was invalid\" in str(e):\n        # show sub-messages and fix the offending group value\n        ...\n    raise","preventionTips":["Make every group's value a TOML array of PEP 508 requirement strings (or {group} refs).","Run DependencyGroupResolver over the raw table in a pre-commit hook to catch init-time errors.","Validate group value types before publishing pyproject.toml."],"tags":["dependency-groups","pep735","toml","validation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}