{"record":{"id":"eef3c61ddcd66b57","repo":"redis/redis-py","slug":"wrong-command-or-module-name-command-name","errorCode":null,"errorMessage":"Wrong command or module name: {command_name}","messagePattern":"Wrong command or module name: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/commands/policies.py","lineNumber":199,"sourceCode":"        pass\n\n\nclass BasePolicyResolver(PolicyResolver):\n    \"\"\"\n    Base class for policy resolvers.\n    \"\"\"\n\n    def __init__(\n        self, policies: PolicyRecords, fallback: Optional[PolicyResolver] = None\n    ) -> None:\n        self._policies = policies\n        self._fallback = fallback\n\n    def resolve(self, command_name: str) -> Optional[CommandPolicies]:\n        parts = command_name.split(\".\")\n\n        if len(parts) > 2:\n            raise ValueError(f\"Wrong command or module name: {command_name}\")\n\n        module, command = parts if len(parts) == 2 else (\"core\", parts[0])\n\n        if self._policies.get(module, None) is None:\n            if self._fallback is not None:\n                return self._fallback.resolve(command_name)\n            else:\n                return None\n\n        if self._policies.get(module).get(command, None) is None:\n            if self._fallback is not None:\n                return self._fallback.resolve(command_name)\n            else:\n                return None\n\n        return self._policies.get(module).get(command)\n\n    @abstractmethod","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/policies.py#L181-L217","documentation":"Raised by BasePolicyResolver.resolve() (redis/commands/policies.py:199) as a ValueError when the command_name string splits on '.' into more than 2 parts. The resolver expects either 'COMMAND' (resolved to core.COMMAND) or 'module.COMMAND'; anything with two or more dots (e.g. 'search.ft.aggregate') is malformed. This is an internal cluster-routing API, not normally called by end users.","triggerScenarios":"Internally calling resolver.resolve('a.b.c') or any command name with >= 2 dots. Happens when a command name is mis-constructed with extra namespace segments, or a module command is double-prefixed.","commonSituations":"Custom policy resolvers, registering a command under a nested module path, or a typo concatenating module prefixes. End users typically only see this if they extend cluster routing or pass malformed command names to internal APIs.","solutions":["Use command names with at most one dot: 'COMMAND' or 'module.COMMAND'.","Strip extra namespace segments before resolving.","If you extended the cluster client with a new command, register it under a single module prefix."],"exampleFix":"# before\nresolver.resolve('search.ft.aggregate')\n# after\nresolver.resolve('search.aggregate')","handlingStrategy":"validation","validationCode":"def safe_resolve_name(command_name):\n    if command_name.count('.') > 1:\n        raise ValueError(f'command name must have at most one dot: {command_name}')\n    return command_name","typeGuard":"def is_valid_command_name(name) -> bool:\n    return isinstance(name, str) and name.count('.') <= 1","tryCatchPattern":"try:\n    resolver.resolve(name)\nexcept ValueError as e:\n    if 'Wrong command' in str(e):\n        # strip extra namespace segments and retry\n        resolver.resolve(name.split('.')[-1])\n    else:\n        raise","preventionTips":["Keep command names flat: 'COMMAND' or 'module.COMMAND'.","Validate names before registering/resolving if you build them dynamically.","This is an internal API - end users should not call resolver.resolve directly."],"tags":["cluster","policies","internal","valueerror","routing"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}