{"id":"c174994ed53db774","repo":"redis/redis-py","slug":"specific-argument-can-be-only-keys-or-strings","errorCode":null,"errorMessage":"specific_argument can be only keys or strings","messagePattern":"specific_argument can be only keys or strings","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":4622,"sourceCode":"        ``value1`` and ``value2`` Can be two strings or two keys\n        ``specific_argument`` Specifying if the arguments to the algorithm\n        will be keys or strings. strings is the default.\n        ``len`` Returns just the len of the match.\n        ``idx`` Returns the match positions in each string.\n        ``minmatchlen`` Restrict the list of matches to the ones of a given\n        minimal length. Can be provided only when ``idx`` set to True.\n        ``withmatchlen`` Returns the matches with the len of the match.\n        Can be provided only when ``idx`` set to True.\n\n        For more information, see https://redis.io/commands/stralgo\n        \"\"\"\n        # check validity\n        supported_algo = [\"LCS\"]\n        if algo not in supported_algo:\n            supported_algos_str = \", \".join(supported_algo)\n            raise DataError(f\"The supported algorithms are: {supported_algos_str}\")\n        if specific_argument not in [\"keys\", \"strings\"]:\n            raise DataError(\"specific_argument can be only keys or strings\")\n        if len and idx:\n            raise DataError(\"len and idx cannot be provided together.\")\n\n        pieces: list[EncodableT] = [algo, specific_argument.upper(), value1, value2]\n        if len:\n            pieces.append(b\"LEN\")\n        if idx:\n            pieces.append(b\"IDX\")\n        try:\n            int(minmatchlen)\n            pieces.extend([b\"MINMATCHLEN\", minmatchlen])\n        except TypeError:\n            pass\n        if withmatchlen:\n            pieces.append(b\"WITHMATCHLEN\")\n\n        return self.execute_command(\n            \"STRALGO\",","sourceCodeStart":4604,"sourceCodeEnd":4640,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/core.py#L4604-L4640","documentation":"Raised by stralgo() when specific_argument is neither 'keys' nor 'strings'. This argument tells Redis whether value1/value2 are key names to look up or literal string values, so only those two spellings are valid.","triggerScenarios":"Calling client.stralgo('LCS', k1, k2, specific_argument='KEY') (wrong case), specific_argument='key' (singular), or any value other than exactly 'keys' or 'strings'.","commonSituations":"Case mismatch; passing the singular form; passing None or an empty string; deriving the value from unvalidated config input.","solutions":["Pass specific_argument='strings' (default) when value1/value2 are literal strings.","Pass specific_argument='keys' when value1/value2 are Redis key names.","Use the lcs() helper which encodes the correct argument automatically."],"exampleFix":"# before\nawait r.stralgo('LCS', k1, k2, specific_argument='key')\n# after\nawait r.stralgo('LCS', k1, k2, specific_argument='keys')","handlingStrategy":"validation","validationCode":"VALID_SPECIFIC = {'keys', 'strings'}\ndef validate_specific_argument(specific_argument: str) -> str:\n    if specific_argument not in VALID_SPECIFIC:\n        raise ValueError(f'specific_argument must be one of {VALID_SPECIFIC}')\n    return specific_argument","typeGuard":"def is_valid_specific_argument(s: str) -> bool:\n    return s in {'keys', 'strings'}","tryCatchPattern":null,"preventionTips":["Use 'strings' (default) for literal values, 'keys' for key lookups.","Prefer the lcs() helper which sets specific_argument correctly.","Watch for casing and singular/plural mistakes."],"tags":["stralgo","validation","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}