{"record":{"id":"abbb71cb2c2f08bf","repo":"redis/redis-py","slug":"the-only-valid-subcommands-are","errorCode":null,"errorMessage":"The only valid subcommands are ","messagePattern":"The only valid subcommands are ","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/json/commands.py","lineNumber":826,"sourceCode":"        subcommand: str,\n        key: str | None = None,\n        path: str | None = Path.root_path(),\n    ) -> Awaitable[int | list[str]]: ...\n\n    def debug(\n        self,\n        subcommand: str,\n        key: str | None = None,\n        path: str | None = Path.root_path(),\n    ) -> (int | list[str]) | Awaitable[int | list[str]]:\n        \"\"\"Return the memory usage in bytes of a value under ``path`` from\n        key ``name``.\n\n        For more information see `JSON.DEBUG <https://redis.io/commands/json.debug>`_.\n        \"\"\"  # noqa\n        valid_subcommands = [\"MEMORY\", \"HELP\"]\n        if subcommand not in valid_subcommands:\n            raise DataError(\"The only valid subcommands are \", str(valid_subcommands))\n        pieces = [subcommand]\n        if subcommand == \"MEMORY\":\n            if key is None:\n                raise DataError(\"No key specified\")\n            pieces.append(key)\n            pieces.append(str(path))\n        return self.execute_command(\"JSON.DEBUG\", *pieces)\n\n    @overload\n    def jsonget(self: SyncClientProtocol, *args, **kwargs) -> JsonType | None: ...\n\n    @overload\n    def jsonget(\n        self: AsyncClientProtocol, *args, **kwargs\n    ) -> Awaitable[JsonType | None]: ...\n\n    @deprecated_function(\n        version=\"4.0.0\", reason=\"redisjson-py supported this, call get directly.\"","sourceCodeStart":808,"sourceCodeEnd":844,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/json/commands.py#L808-L844","documentation":"Raised by JSON.DEBUG (redis/commands/json/commands.py:826) as a DataError when the subcommand argument is not 'MEMORY' or 'HELP'. Note the message itself is malformed: the call is `raise DataError('The only valid subcommands are ', str(valid_subcommands))` which passes the list as a second positional arg to DataError rather than embedding it in the message, so the rendered text is truncated and does not show the allowed values.","triggerScenarios":"Calling client.json().debug('STATS') or any subcommand string other than 'MEMORY' or 'HELP' (case-sensitive, must be uppercase).","commonSituations":"Assuming JSON.DEBUG supports subcommands from another Redis variant, passing lowercase 'memory', or guessing subcommand names. The unhelpful truncated message makes discovery harder.","solutions":["Use only 'MEMORY' (with a key) or 'HELP' as the subcommand.","For 'MEMORY' you must also pass a key argument or you hit the separate 'No key specified' error (347).","Pass the exact uppercase string; matching is case-sensitive."],"exampleFix":"# before\nclient.json().debug('stats')\n# after\nclient.json().debug('MEMORY', 'mykey')","handlingStrategy":"validation","validationCode":"VALID_DEBUG_SUBCOMMANDS = {'MEMORY', 'HELP'}\n\ndef safe_json_debug(subcommand):\n    sub = subcommand.upper()\n    if sub not in VALID_DEBUG_SUBCOMMANDS:\n        raise ValueError(f'JSON.DEBUG subcommand must be one of {sorted(VALID_DEBUG_SUBCOMMANDS)}')\n    return sub","typeGuard":"def is_valid_debug_sub(s) -> bool:\n    return isinstance(s, str) and s.upper() in {'MEMORY', 'HELP'}","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.json().debug(sub)\nexcept DataError:\n    client.json().debug('HELP')  # discover supported subcommands","preventionTips":["Use only 'MEMORY' or 'HELP' (uppercase).","Do not trust the truncated error text - it does not list the valid values.","For MEMORY always supply a key (see error 347)."],"tags":["json","jsondebug","argument-validation","dataerror","redisjson"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}