{"id":"d760270f9fceac3d","repo":"redis/redis-py","slug":"when-using-groups-the-get-argument-must-be-spe","errorCode":null,"errorMessage":"when using \"groups\" the \"get\" argument must be specified and contain at least two keys","messagePattern":"when using \"groups\" the \"get\" argument must be specified and contain at least two keys","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":5454,"sourceCode":"        if get is not None:\n            # If get is a string assume we want to get a single value.\n            # Otherwise assume it's an iterable and we want to get multiple\n            # values. We can't just iterate blindly because strings are\n            # iterable.\n            if isinstance(get, (bytes, str)):\n                pieces.extend([b\"GET\", get])\n            else:\n                for g in get:\n                    pieces.extend([b\"GET\", g])\n        if desc:\n            pieces.append(b\"DESC\")\n        if alpha:\n            pieces.append(b\"ALPHA\")\n        if store is not None:\n            pieces.extend([b\"STORE\", store])\n        if groups:\n            if not get or isinstance(get, (bytes, str)) or len(get) < 2:\n                raise DataError(\n                    'when using \"groups\" the \"get\" argument '\n                    \"must be specified and contain at least \"\n                    \"two keys\"\n                )\n\n        options = {\"groups\": len(get) if groups else None}\n        options[\"keys\"] = [name]\n        return self.execute_command(\"SORT\", *pieces, **options)\n\n    @overload\n    def sort_ro(\n        self: SyncClientProtocol,\n        key: str,\n        start: int | None = None,\n        num: int | None = None,\n        by: str | None = None,\n        get: list[str] | None = None,\n        desc: bool = False,","sourceCodeStart":5436,"sourceCodeEnd":5472,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/core.py#L5436-L5472","documentation":"Raised by sort() when groups=True but the get argument is missing, is a single string, or has fewer than two entries. groups instructs Redis to return tuples built from multiple GET lookups, so at least two GET patterns are required to form each group.","triggerScenarios":"Calling client.sort(key, groups=True) with no get, or client.sort(key, groups=True, get='field_*') with a single pattern, or get=['a'] with one element.","commonSituations":"Enabling groups for multi-field joins but supplying a single GET pattern; passing a string instead of a list for get when groups is set.","solutions":["Provide get as a list of at least two patterns, e.g. sort(key, groups=True, get=['obj_*->a', 'obj_*->b']).","Drop groups=True if you only need a single GET pattern.","Ensure get is a list/tuple (not a bare string) when groups is enabled."],"exampleFix":"# before\nawait r.sort('mykey', groups=True, get='obj_*->name')\n# after\nawait r.sort('mykey', groups=True, get=['obj_*->name', 'obj_*->age'])","handlingStrategy":"validation","validationCode":"def validate_sort_groups(groups: bool, get):\n    if groups:\n        if not get or isinstance(get, (bytes, str)) or len(get) < 2:\n            raise ValueError('groups=True requires get as a list of at least two patterns')\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only enable groups when you have 2+ GET patterns.","Pass get as a list (not a bare string) whenever groups is True.","Drop groups if a single GET pattern suffices."],"tags":["sort","groups","validation","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}