redis/redis-py · error · DataError
The supported algorithms are
Error message
The supported algorithms are: {supported_algos_str} What it means
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.
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().
Example fix
# before client.stralgo(algo='LCS_STR', value1='ohmytext', value2='mynewtext') # after client.stralgo(algo='LCS', value1='ohmytext', value2='mynewtext')
Defensive patterns
Strategy: validation
Validate before calling
if algo != 'LCS':
raise ValueError("stralgo algo must be 'LCS'")
client.stralgo(algo=algo, value1=v1, value2=v2) Type guard
from typing import Literal
def is_supported_algo(a: str) -> bool:
return a == 'LCS'
# usage
algo: Literal['LCS'] = 'LCS' Try / catch
from redis.exceptions import DataError
try:
client.stralgo(algo=algo, value1=v1, value2=v2)
except DataError as e:
if 'supported algorithms' in str(e):
algo = 'LCS'
client.stralgo(algo=algo, value1=v1, value2=v2) Prevention
- 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.
When it happens
Trigger: Calling client.stralgo(algo='EDIT', value1=..., value2=...), client.stralgo('lcs', ...) (wrong case), or passing any string other than 'LCS' as the algo parameter.
Common situations: 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.
Related errors
- specific_argument can be only keys or strings
- len and idx cannot be provided together.
- ACL LOG count must be an integer
- bit must be 0 or 1
- Both start and end must be specified
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/ff77e39cbfb18a19.
Report an issue: GitHub.
Appendix: source
Thrown at redis/commands/core.py:4620
``algo`` Right now must be LCS
``value1`` and ``value2`` Can be two strings or two keys
``specific_argument`` Specifying if the arguments to the algorithm
will be keys or strings. strings is the default.
``len`` Returns just the len of the match.
``idx`` Returns the match positions in each string.
``minmatchlen`` Restrict the list of matches to the ones of a given
minimal length. Can be provided only when ``idx`` set to True.
``withmatchlen`` Returns the matches with the len of the match.
Can be provided only when ``idx`` set to True.
For more information, see https://redis.io/commands/stralgo
"""
# check validity
supported_algo = ["LCS"]
if algo not in supported_algo:
supported_algos_str = ", ".join(supported_algo)
raise DataError(f"The supported algorithms are: {supported_algos_str}")
if specific_argument not in ["keys", "strings"]:
raise DataError("specific_argument can be only keys or strings")
if len and idx:
raise DataError("len and idx cannot be provided together.")
pieces: list[EncodableT] = [algo, specific_argument.upper(), value1, value2]
if len:
pieces.append(b"LEN")
if idx:
pieces.append(b"IDX")
try:
int(minmatchlen)
pieces.extend([b"MINMATCHLEN", minmatchlen])
except TypeError:
pass
if withmatchlen:
pieces.append(b"WITHMATCHLEN")
View on GitHub (pinned to 6a6b581b48)