{"id":"ea42b57de44b8204","repo":"redis/redis","slug":"invalid-address-format-s","errorCode":null,"errorMessage":"Invalid address format: %s\n","messagePattern":"Invalid address format: (.+?)\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/redis-cli.c","lineNumber":7327,"sourceCode":"    } else if (config.stdin_tag_arg) {\n        sdsfree(config.cluster_manager_command.stdin_arg);\n    }\n    freeClusterManager();\n\n    exit(success ? 0 : 1);\n}\n\n/* Cluster Manager Commands */\n\nstatic int clusterManagerCommandCreate(int argc, char **argv) {\n    int i, j, success = 1;\n    cluster_manager.nodes = listCreate();\n    for (i = 0; i < argc; i++) {\n        char *addr = argv[i];\n        char *ip = NULL;\n        int port = 0;\n        if (!parseClusterNodeAddress(addr, &ip, &port, NULL)) {\n            fprintf(stderr, \"Invalid address format: %s\\n\", addr);\n            return 0;\n        }\n\n        clusterManagerNode *node = clusterManagerNewNode(ip, port, 0);\n        if (!clusterManagerNodeConnect(node)) {\n            freeClusterManagerNode(node);\n            return 0;\n        }\n        char *err = NULL;\n        if (!clusterManagerNodeIsCluster(node, &err)) {\n            clusterManagerPrintNotClusterNodeError(node, err);\n            if (err) zfree(err);\n            freeClusterManagerNode(node);\n            return 0;\n        }\n        err = NULL;\n        if (!clusterManagerNodeLoadInfo(node, 0, &err)) {\n            if (err) {","sourceCodeStart":7309,"sourceCodeEnd":7345,"githubUrl":"https://github.com/redis/redis/blob/3acc0c49cf5ad2af9425d333e62728342dd6159b/src/redis-cli.c#L7309-L7345","documentation":"Printed by clusterManagerCommandCreate (src/redis-cli.c:7327) when one of the `host:port` arguments passed to `redis-cli --cluster create` cannot be split into ip and port by parseClusterNodeAddress (the address contains no `:`). The create command refuses to start because it cannot even build the node list.","triggerScenarios":"Run `redis-cli --cluster create n1 n2 n3 ...` where any argument is a bare hostname/IP with no `:port`, or contains only a port. parseClusterNodeAddress returns 0 when strrchr(addr, ':') is NULL.","commonSituations":"Copy-pasting `redis-cli --cluster create host1 host2 host3` instead of `host1:7000 host2:7000 host3:7000`; shell variable that expanded empty so the port segment is missing; accidentally passing the cluster bus port as a separate token.","solutions":["Rewrite every node argument in `ip:port` form, e.g. `127.0.0.1:7000 127.0.0.1:7001`.","If using hostnames, still append the port: `node1.example.com:7000`.","For IPv6 literals use the bracketed form `[::1]:7000` so the port-colon is unambiguous.","Double-check shell expansion: `echo` your full command first to confirm no empty `$VAR`."],"exampleFix":"// before\nredis-cli --cluster create 127.0.0.1 127.0.0.1 127.0.0.1 --cluster-replicas 1\n// after\nredis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 --cluster-replicas 1","handlingStrategy":"validation","validationCode":"// Validate an address string in 'host:port' or 'host port' form BEFORE passing it in.\nfunction validateAddressFormat(addr) {\n  if (typeof addr !== 'string' || addr.trim().length === 0) {\n    throw new Error('Invalid address format: empty');\n  }\n  const m = addr.trim().match(/^(\\[[^\\]]+\\]|[^:\\[\\]\\s]+)(?::|\\s+)(\\d{1,5})$/);\n  if (!m) throw new Error(`Invalid address format: ${addr}`);\n  const port = Number(m[2]);\n  if (!Number.isInteger(port) || port < 1 || port > 65535) {\n    throw new Error(`Invalid port in address: ${addr}`);\n  }\n  return { host: m[1].replace(/^\\[|\\]$/g, ''), port };\n}\nconst ep = validateAddressFormat(inputAddr);","typeGuard":"// Narrow a string to a confirmed 'host:port' address.\nfunction isHostPortString(v) {\n  if (typeof v !== 'string') return false;\n  const m = v.trim().match(/^(\\[[^\\]]+\\]|[^:\\[\\]\\s]+)(?::|\\s+)(\\d{1,5})$/);\n  if (!m) return false;\n  const p = Number(m[2]);\n  return Number.isInteger(p) && p > 0 && p < 65536;\n}","tryCatchPattern":"try {\n  result = parseAddress(userInput);\n} catch (e) {\n  if (/Invalid address format/i.test(String(e.message))) {\n    throw new Error(`Rejecting malformed cluster address from caller: '${userInput}'`);\n  }\n  throw e;\n}","preventionTips":["Normalize every address input through one validator before it reaches any cluster API","Accept both 'host:port' and 'host port' but emit a single canonical form internally","Bracket IPv6 literals (e.g. [::1]:6379) so the colon in the address is unambiguous","Reject empty/whitespace-only strings explicitly rather than letting them fall through","Validate at the system boundary (CLI/HTTP), not deep inside business logic"],"tags":["cluster-manager","create","arguments","parsing","cli-usage"],"analyzedSha":"3acc0c49cf5ad2af9425d333e62728342dd6159b","analyzedAt":"2026-08-01T22:07:56.715Z","schemaVersion":2}