{"record":{"id":"16e1800381cebfe2","repo":"redis/redis-py","slug":"no-key-specified","errorCode":null,"errorMessage":"No key specified","messagePattern":"No key specified","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/json/commands.py","lineNumber":830,"sourceCode":"\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.\"\n    )\n    def jsonget(self, *args, **kwargs) -> (JsonType | None) | Awaitable[\n        JsonType | None\n    ]:","sourceCodeStart":812,"sourceCodeEnd":848,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/json/commands.py#L812-L848","documentation":"Raised by JSON.DEBUG (redis/commands/json/commands.py:830) as a DataError when subcommand is 'MEMORY' but no key argument is supplied. The MEMORY subcommand requires a key (and optional path) to measure, so the library rejects the call before sending JSON.DEBUG MEMORY with no target.","triggerScenarios":"Calling client.json().debug('MEMORY') or client.json().debug('MEMORY', None). The key parameter defaults to None and is only checked when subcommand == 'MEMORY'.","commonSituations":"Forgetting the key, reusing a debug('HELP') call signature for MEMORY, or a variable that resolved to None.","solutions":["Pass a non-None key: client.json().debug('MEMORY', 'mykey').","Optionally also pass a path: client.json().debug('MEMORY', 'mykey', '$.field').","For HELP no key is needed."],"exampleFix":"# before\nclient.json().debug('MEMORY')\n# after\nclient.json().debug('MEMORY', 'mykey')","handlingStrategy":"validation","validationCode":"def safe_json_debug_memory(key):\n    if not key:\n        raise ValueError('JSON.DEBUG MEMORY requires a key')\n    return key","typeGuard":"def has_debug_key(key) -> bool:\n    return isinstance(key, str) and bool(key)","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.json().debug('MEMORY', key)\nexcept DataError as e:\n    if 'No key' in str(e):\n        raise  # caller must supply a key\n    raise","preventionTips":["Always pass a non-empty key with the MEMORY subcommand.","Do not reuse the debug('HELP') call signature for MEMORY.","Validate keys at the boundary before reaching the client."],"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"}