{"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/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/json/commands.py#L812-L848","documentation":"Raised by JSON.debug() when subcommand is 'MEMORY' but no key argument was supplied. The MEMORY subcommand reports bytes used by a value at a specific key, so the key is mandatory; HELP is the only subcommand that works without one.","triggerScenarios":"Call client.json().debug('MEMORY') with key left as the default None, or client.json().debug('MEMORY', None).","commonSituations":"Forgetting the positional key; passing key from a variable that is None on missing input; refactoring that drops the key argument.","solutions":["Always pass a key with the MEMORY subcommand: debug('MEMORY', 'mykey').","Guard before calling: if key is None: skip or raise your own error.","Use debug('HELP') if you only want usage text."],"exampleFix":"// before\nclient.json().debug('MEMORY')\n// after\nclient.json().debug('MEMORY', 'mykey')","handlingStrategy":"validation","validationCode":"def json_debug_memory(client, key, path=\"$\"):\n    if key is None:\n        raise ValueError(\"MEMORY subcommand requires a key\")\n    return client.json().debug(\"MEMORY\", key, path)","typeGuard":"def has_key(v) -> bool:\n    return v is not None and (not isinstance(v, str) or v != \"\")","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.json().debug(\"MEMORY\", key)\nexcept DataError as e:\n    if \"No key specified\" in str(e):\n        raise ValueError(\"caller must supply a non-None key\") from e\n    raise","preventionTips":["Require key positionally in your wrapper so it can't be silently None.","Distinguish 'HELP' (no key) from 'MEMORY' (key required) at the API boundary.","Validate request payloads that drive JSON.DEBUG before invoking the client."],"tags":["redis-json","validation","json-debug","missing-argument","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}