{"record":{"id":"863b4fad3d277284","repo":"pypa/pip","slug":"dependency-groups-table-was-malformed-in-path","errorCode":null,"errorMessage":"[dependency-groups] table was malformed in {path}. Cannot resolve '--group' option.","messagePattern":"\\[dependency-groups\\] table was malformed in (.+?)\\. Cannot resolve '--group' option\\.","errorType":"validation","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/req/req_dependency_group.py","lineNumber":55,"sourceCode":"                f\"from '{path}': {'; '.join(messages)}\"\n            ) from eg\n\n\ndef _build_resolvers(paths: Iterable[str]) -> dict[str, Any]:\n    resolvers = {}\n    for path in paths:\n        if path in resolvers:\n            continue\n\n        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    \"\"\"","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/req/req_dependency_group.py#L37-L73","documentation":"The pyproject.toml has a 'dependency-groups' key but its value is not a TOML table (dict). The resolver checks isinstance(raw_dependency_groups, dict) and rejects arrays, strings, numbers, or inline tables used incorrectly. The [dependency-groups] table must be a mapping of group names to requirement lists.","triggerScenarios":"Writing 'dependency-groups = [\"pytest\"]' (array value) or 'dependency-groups = \"dev\"' (string value) instead of a proper TOML table with [dependency-groups] as a section header.","commonSituations":"Confusion between TOML table syntax (section header [dependency-groups]) and key-value syntax (dependency-groups = ...). Migrating from an array-based custom convention.","solutions":["Use TOML section header syntax: '[dependency-groups]' followed by 'groupname = [\"pkg1\", \"pkg2\"]'","Ensure the dependency-groups value is a dict/table, not an array or scalar"],"exampleFix":"# before — pyproject.toml\ndependency-groups = [\"pytest\", \"ruff\"]\n\n# after\n[dependency-groups]\ndev = [\"pytest\", \"ruff\"]","handlingStrategy":"validation","validationCode":"from pip._internal.utils.compat import tomllib\n\ndef is_dependency_groups_well_formed(path: str) -> bool:\n    with open(path, \"rb\") as fp:\n        data = tomllib.load(fp)\n    return isinstance(data.get(\"dependency-groups\"), dict)\n\nif not is_dependency_groups_well_formed(\"pyproject.toml\"):\n    print(\"[dependency-groups] must be a TOML table, not an array or string\")","typeGuard":"from pip._internal.utils.compat import tomllib\n\ndef is_valid_dependency_groups_table(path: str) -> bool:\n    \"\"\"Type guard: True if dependency-groups is a dict/table.\"\"\"\n    with open(path, \"rb\") as fp:\n        data = tomllib.load(fp)\n    return isinstance(data.get(\"dependency-groups\"), dict)","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 \"malformed\" in str(e):\n        print(\"Use TOML section header [dependency-groups], not key = value\")\n    else:\n        raise","preventionTips":["Use TOML section-header syntax '[dependency-groups]' not 'dependency-groups = ...'","Validate that the value is a dict with a TOML linter","Follow PEP 735 examples for correct table structure"],"tags":["pip","dependency-groups","pep735","toml","configuration"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}