{"record":{"id":"ff77e39cbfb18a19","repo":"redis/redis-py","slug":"the-supported-algorithms-are-supported-algos-str","errorCode":null,"errorMessage":"The supported algorithms are: {supported_algos_str}","messagePattern":"The supported algorithms are: (.+?)","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":4620,"sourceCode":"\n        ``algo`` Right now must be LCS\n        ``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","sourceCodeStart":4602,"sourceCodeEnd":4638,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L4602-L4638","documentation":"Raised by stralgo() when the algo argument is not 'LCS'. LCS (longest common substring) is currently the only algorithm the STRALGO command implements, so the client rejects any other value immediately rather than sending an invalid command to the server. It is a DataError.","triggerScenarios":"Calling client.stralgo(algo='EDIT', value1=..., value2=...), client.stralgo('lcs', ...) (wrong case), or passing any string other than 'LCS' as the algo parameter.","commonSituations":"Misspelling the algorithm name, using wrong case, or assuming a newer algorithm is available when targeting an older Redis server. Programmatic algo selection where the source value is not constrained.","solutions":["Pass algo='LCS' (uppercase) to stralgo().","If you need a different string algorithm, use the dedicated LCS key command (client.lcs()) instead of stralgo()."],"exampleFix":"# before\nclient.stralgo(algo='LCS_STR', value1='ohmytext', value2='mynewtext')\n\n# after\nclient.stralgo(algo='LCS', value1='ohmytext', value2='mynewtext')","handlingStrategy":"validation","validationCode":"if algo != 'LCS':\n    raise ValueError(\"stralgo algo must be 'LCS'\")\nclient.stralgo(algo=algo, value1=v1, value2=v2)","typeGuard":"from typing import Literal\n\ndef is_supported_algo(a: str) -> bool:\n    return a == 'LCS'\n\n# usage\nalgo: Literal['LCS'] = 'LCS'","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.stralgo(algo=algo, value1=v1, value2=v2)\nexcept DataError as e:\n    if 'supported algorithms' in str(e):\n        algo = 'LCS'\n        client.stralgo(algo=algo, value1=v1, value2=v2)","preventionTips":["Always pass algo='LCS' literally; there is currently no alternative.","Prefer client.lcs(key1, key2) for the key-based LCS use case, which has no algo parameter."],"tags":["stralgo","lcs","validation","argument-value"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}