{"record":{"id":"9fe8a9a7c0cbef63","repo":"iflytek/astron-agent","slug":"invalid-redis-address-format-cluster-addr","errorCode":null,"errorMessage":"Invalid Redis address format: {cluster_addr}","messagePattern":"Invalid Redis address format: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/plugin/link/domain/models/utils.py","lineNumber":285,"sourceCode":"        logger.debug(\"redis cluster init in progress\")\n        if os.getenv(const.REDIS_CLUSTER_ADDR_KEY):\n            host_port_pairs = cluster_addr.split(\",\")\n            cluster_nodes = []\n            for pair in host_port_pairs:\n                match = re.match(r\"([^:]+):(\\d+)\", pair)\n                if match:\n                    host = match.group(1)\n                    port = match.group(2)\n                    cluster_nodes.append({\"host\": host, \"port\": port})\n            return RedisCluster(startup_nodes=cluster_nodes, password=password)\n\n        match = re.match(r\"([^:]+):(\\d+)\", cluster_addr)\n        if match:\n            host = match.group(1)\n            port = match.group(2)\n            return redis.Redis(host=host, port=int(port), password=password)\n        else:\n            raise ValueError(f\"Invalid Redis address format: {cluster_addr}\")\n\n    # check connection\n    def is_connected(self) -> bool:\n        \"\"\"\n        Check if the Redis client is connected.\n        \"\"\"\n        try:\n            self._client.ping()\n            return True\n        except redis.exceptions.ConnectionError:\n            return False\n\n    def get(self, key: str) -> Optional[Any]:\n        \"\"\"\n        Retrieve an item from the cache.\n\n        Args:\n            key: The key of the item to retrieve.","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/link/domain/models/utils.py#L267-L303","documentation":"init_redis_cluster() parses the Redis address with the regex r\"([^:]+):(\\d+)\". When REDIS_CLUSTER_ADDR_KEY is unset it treats the whole address as a single host:port; if it does not match that pattern, ValueError is raised. Note: the cluster branch silently skips non-matching pairs instead of raising — this error only fires in single-node mode.","triggerScenarios":"Passing 'localhost' or 'myhost' with no :port; using a URL form like 'redis://host:6379' or 'host:6379,other:6380' while the cluster env var is unset (regex fails on 'redis://host:6379'); IPv6 addresses containing colons; trailing whitespace or protocol prefixes; empty string.","commonSituations":"Config/env var set to a redis:// URL copied from documentation; forgetting the port (assuming default 6379); leaving the cluster-mode env var unset while supplying a comma-separated cluster address list, so only the first pair is parsed and everything else is silently dropped.","solutions":["Format the address as plain 'host:port', e.g. '127.0.0.1:6379' — strip any redis:// prefix.","If using a comma-separated cluster list, make sure the cluster-mode env var (const.REDIS_CLUSTER_ADDR_KEY) is set, otherwise only single-node parsing runs.","Validate the config value before constructing RedisService: split on ':' and check there are exactly 2 parts with a numeric port.","For IPv6 hosts use bracketed notation and adjust parsing, since the regex will mis-split colons."],"exampleFix":"// before\nRedisService(\"redis://127.0.0.1:6379\", password=pwd)\nRedisService(\"localhost\", password=pwd)\n// after\nRedisService(\"127.0.0.1:6379\", password=pwd)","handlingStrategy":"validation","validationCode":"import re\naddr = os.environ[\"REDIS_ADDR\"]\npairs = addr.split(\",\")\nfor p in pairs:\n    if not re.fullmatch(r\"[^:]+:\\d+\", p):\n        raise ValueError(f\"REDIS_ADDR must be host:port (comma-separated), got {p!r}\")","typeGuard":null,"tryCatchPattern":"try:\n    redis_service = RedisService(cluster_addr, password=pwd)\nexcept ValueError as e:\n    logger.error(\"bad REDIS_ADDR %r — expected host:port without redis:// prefix\", e)","preventionTips":["Store the address as plain host:port; strip any redis:// scheme before passing it in.","If using comma-separated cluster lists, ensure the cluster-mode env var is set so the cluster branch runs.","Validate the format in config loading with a regex before constructing RedisService."],"tags":["redis","configuration","parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}