{"record":{"id":"de57d97eb7c59190","repo":"redis/redis-py","slug":"with-labels-and-select-labels-cannot-be-provided-t","errorCode":null,"errorMessage":"with_labels and select_labels cannot be provided together.","messagePattern":"with_labels and select_labels cannot be provided together\\.","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/timeseries/commands.py","lineNumber":1947,"sourceCode":"            )\n        params.append(\"FILTER\")\n        params.extend(filters)\n\n    @staticmethod\n    def _append_uncompressed(params: list[EncodableT], uncompressed: bool | None):\n        \"\"\"Append UNCOMPRESSED tag to params.\"\"\"\n        if uncompressed:\n            params.extend([\"ENCODING\", \"UNCOMPRESSED\"])\n\n    @staticmethod\n    def _append_with_labels(\n        params: list[EncodableT],\n        with_labels: bool | None,\n        select_labels: list[str] | None,\n    ):\n        \"\"\"Append labels behavior to params.\"\"\"\n        if with_labels and select_labels:\n            raise DataError(\n                \"with_labels and select_labels cannot be provided together.\"\n            )\n\n        if with_labels:\n            params.extend([\"WITHLABELS\"])\n        if select_labels:\n            params.extend([\"SELECTED_LABELS\", *select_labels])\n\n    @staticmethod\n    def _append_groupby_reduce(\n        params: list[EncodableT], groupby: str | None, reduce: str | None\n    ):\n        \"\"\"Append GROUPBY REDUCE property to params.\"\"\"\n        if groupby is not None and reduce is not None:\n            params.extend([\"GROUPBY\", groupby, \"REDUCE\", reduce.upper()])\n\n    @staticmethod\n    def _append_retention(params: list[EncodableT], retention: int | None):","sourceCodeStart":1929,"sourceCodeEnd":1965,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/timeseries/commands.py#L1929-L1965","documentation":"Raised by _append_with_labels (used by TS.MRANGE / TS.MGET family) when both with_labels=True and a non-empty select_labels are supplied. WITHLABELS returns all labels; SELECTED_LABELS returns a subset — they are mutually exclusive on the wire.","triggerScenarios":"Calling mrange(..., with_labels=True, select_labels=['region']) or mget with both set.","commonSituations":"A shared kwargs dict where with_labels defaults to True and select_labels is also populated. Wrapper code that sets both 'to be safe'.","solutions":["Use with_labels=True alone for all labels.","Use select_labels=[...] alone for a subset of labels.","Ensure with_labels is False/None whenever select_labels is provided."],"exampleFix":"// before\nclient.ts().mrange(f, t, filters,\n    with_labels=True, select_labels=['region'])\n// after\nclient.ts().mrange(f, t, filters, select_labels=['region'])\n# or\nclient.ts().mrange(f, t, filters, with_labels=True)","handlingStrategy":"validation","validationCode":"if select_labels:\n    with_labels = False\nclient.ts().mrange(..., with_labels=with_labels, select_labels=select_labels)","typeGuard":null,"tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.ts().mrange(..., with_labels=with_labels, select_labels=select_labels)\nexcept DataError:\n    client.ts().mrange(..., select_labels=select_labels)","preventionTips":["Never set with_labels and select_labels together.","Default with_labels to False when select_labels is populated."],"tags":["redistimeseries","mrange","labels","argument-validation"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}