{"id":"791f15a0030738fc","repo":"redis/redis-py","slug":"filters-cannot-be-an-empty-collection-pass-none-t","errorCode":null,"errorMessage":"filters cannot be an empty collection; pass None to query all indexed series.","messagePattern":"filters cannot be an empty collection; pass None to query all indexed series\\.","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/timeseries/commands.py","lineNumber":1926,"sourceCode":"\n    @staticmethod\n    def _append_filter_expressions(\n        params: list[EncodableT], filters: Iterable[str] | None\n    ):\n        \"\"\"Append the optional FILTER clause for TS.QUERYLABELS.\n\n        ``None`` omits ``FILTER`` entirely (the documented all-series query);\n        an explicitly empty collection is a local usage error, since silently\n        widening to all series would be surprising. Any iterable is accepted and\n        materialized once so single-pass iterators are handled correctly.\n        Expressions are passed through verbatim, without parsing, reordering, or\n        normalizing.\n        \"\"\"\n        if filters is None:\n            return\n        filters = list(filters)\n        if not filters:\n            raise DataError(\n                \"filters cannot be an empty collection; pass None to query \"\n                \"all indexed series.\"\n            )\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    ):","sourceCodeStart":1908,"sourceCodeEnd":1944,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/timeseries/commands.py#L1908-L1944","documentation":"Raised by TS.QUERYLABELS parameter building (_append_filter_expressions) when filters is passed as an explicitly empty collection. None means 'query all series' (FILTER omitted); an empty collection is ambiguous and would silently widen the query, so the library treats it as a usage error. Pass None to query everything, or a non-empty list of filter expressions.","triggerScenarios":"client.ts().querylabels(filters=[]) or querylabels(filters=exprs) where exprs is an empty list. Also querylabels('region', filters=[]) for the VALUES form.","commonSituations":"Forwarding an optional filter list that resolved to empty; migrating from TS.QUERYINDEX which accepts different semantics; assuming [] means 'all'.","solutions":["Pass None (or omit the argument) to query all indexed series: client.ts().querylabels() or querylabels(filters=None).","Provide at least one filter expression: querylabels(filters=['region=us']).","Normalize optional input: filters = filters or None before calling."],"exampleFix":"// before\nclient.ts().querylabels(filters=selected_filters)  # empty list\n// after\nclient.ts().querylabels(filters=selected_filters or None)","handlingStrategy":"validation","validationCode":"def coerce_filters(filters):\n    # None means 'all series'; empty collection is rejected by the lib\n    if filters is not None and len(list(filters)) == 0:\n        return None\n    return filters\n\n# usage: client.ts().querylabels(filters=coerce_filters(f))","typeGuard":"def filters_ok(filters) -> bool:\n    return filters is None or len(list(filters)) > 0","tryCatchPattern":"try:\n    client.ts().querylabels(filters=f)\nexcept Exception as e:\n    if 'empty collection' in str(e):\n        client.ts().querylabels()  # query all\n    else:\n        raise","preventionTips":["Pass None, not [], when you mean 'all series'.","Normalize optional filters: filters = filters or None.","Remember [] is an error, None is valid."],"tags":["redistimeseries","timeseries","querylabels","filter","argument-error"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}