{"record":{"id":"d0a0ad331642c8e9","repo":"redis/redis-py","slug":"at-least-one-tag-must-be-specified","errorCode":null,"errorMessage":"At least one tag must be specified","messagePattern":"At least one tag must be specified","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/commands/search/querystring.py","lineNumber":10,"sourceCode":"def tags(*t):\n    \"\"\"\n    Indicate that the values should be matched to a tag field\n\n    ### Parameters\n\n    - **t**: Tags to search for\n    \"\"\"\n    if not t:\n        raise ValueError(\"At least one tag must be specified\")\n    return TagValue(*t)\n\n\ndef between(a, b, inclusive_min=True, inclusive_max=True):\n    \"\"\"\n    Indicate that value is a numeric range\n    \"\"\"\n    return RangeValue(a, b, inclusive_min=inclusive_min, inclusive_max=inclusive_max)\n\n\ndef equal(n):\n    \"\"\"\n    Match a numeric value\n    \"\"\"\n    return between(n, n)\n\n\ndef lt(n):","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/search/querystring.py#L1-L28","documentation":"Raised by redis.commands.search.querystring.tags() when called with no positional arguments. The helper builds a tag query value ({tag1 | tag2}); with no tags there is nothing to match, which is almost always a caller bug.","triggerScenarios":"Calling tags() with no args, or tags(*[]) where the unpacked list is empty. Building a dynamic tag query from a list that happens to be empty.","commonSituations":"User-selected filter that produced zero tags. Code that maps an empty collection through tags() without a guard.","solutions":["Guard before calling: only call tags(*items) when items is non-empty.","If an empty tag set means 'no filter', omit the tag condition from the querystring entirely.","Provide at least one tag value."],"exampleFix":"// before\nnode = intersect(category=tags(*user_categories))\n// after\nif user_categories:\n    node = intersect(category=tags(*user_categories))\nelse:\n    node = intersect()  # no category constraint","handlingStrategy":"validation","validationCode":"if tags_list:\n    val = tags(*tags_list)\nelse:\n    val = None  # omit the tag condition","typeGuard":null,"tryCatchPattern":"try:\n    val = tags(*items)\nexcept ValueError:\n    val = None","preventionTips":["Guard empty collections before building querystring values.","Treat 'no tags' as 'no filter', not as an empty tag set."],"tags":["redisearch","querystring","tag-query","argument-validation"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}