{"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/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/core.py#L4602-L4638","documentation":"Raised by stralgo() when the algo argument is not one of the supported values. Currently the only supported algorithm is 'LCS' (longest common substring). The check guards against typos or unsupported algorithm names before the command is sent to Redis.","triggerScenarios":"Calling client.stralgo('lcs', ...) with wrong casing, or client.stralgo('EDIT', ...) / any string other than exactly 'LCS'.","commonSituations":"Case mismatch ('lcs' vs 'LCS'); copy-paste from docs referencing a future algorithm name; dynamic algo selection from user input without validation.","solutions":["Pass algo='LCS' (uppercase, exact match).","Prefer the dedicated lcs() method which does not require the algo argument.","Validate user-supplied algorithm strings against {'LCS'} before calling stralgo()."],"exampleFix":"# before\nawait r.stralgo('lcs', 'ohmytext', 'mynewtext', specific_argument='strings')\n# after\nawait r.stralgo('LCS', 'ohmytext', 'mynewtext', specific_argument='strings')","handlingStrategy":"validation","validationCode":"SUPPORTED_ALGOS = {'LCS'}\ndef validate_stralgo_algo(algo: str) -> str:\n    if algo not in SUPPORTED_ALGOS:\n        raise ValueError(f'algo must be one of {SUPPORTED_ALGOS}, got {algo!r}')\n    return algo","typeGuard":"def is_supported_algo(algo: str) -> bool:\n    return algo in {'LCS'}","tryCatchPattern":null,"preventionTips":["Hard-code algo='LCS' or prefer the lcs() helper.","Validate user-supplied algorithm strings against {'LCS'} before calling stralgo().","Watch for case sensitivity: only uppercase 'LCS' is accepted."],"tags":["stralgo","lcs","validation","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}