{"record":{"id":"9810ec4c49d34237","repo":"databendlabs/databend","slug":"require-1-or-2-addresses-in-peer-str","errorCode":null,"errorMessage":"require 1 or 2 addresses in peer str: {}","messagePattern":"require 1 or 2 addresses in peer str: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/control/src/import.rs","lineNumber":160,"sourceCode":"///\n/// Raw config is: `<NodeId>=<raft-api-host>:<raft-api-port>[,...]`, e.g. `1=localhost:29103` or `1=localhost:29103,0.0.0.0:19191`\n/// The second part is obsolete grpc api address and will be just ignored. Databend-meta loads Grpc address from config file when starting up.\nfn build_nodes(initial_cluster: Vec<String>, id: u64) -> anyhow::Result<BTreeMap<NodeId, Node>> {\n    eprintln!(\"Initialize Cluster: id={}, {:?}\", id, initial_cluster);\n\n    let mut nodes = BTreeMap::new();\n    for peer in initial_cluster {\n        eprintln!(\"peer:{}\", peer);\n\n        let id_addrs: Vec<&str> = peer.split('=').collect();\n        if id_addrs.len() != 2 {\n            return Err(anyhow::anyhow!(\"invalid peer str: {}\", peer));\n        }\n        let id = u64::from_str(id_addrs[0])?;\n\n        let addrs: Vec<&str> = id_addrs[1].split(',').collect();\n        if addrs.len() > 2 || addrs.is_empty() {\n            return Err(anyhow::anyhow!(\n                \"require 1 or 2 addresses in peer str: {}\",\n                peer\n            ));\n        }\n        let url = Url::parse(&format!(\"http://{}\", addrs[0]))?;\n        let endpoint = match (url.host_str(), url.port()) {\n            (Some(addr), Some(port)) => Endpoint::new(addr, port),\n            _ => {\n                return Err(anyhow::anyhow!(\"invalid peer raft addr: {}\", addrs[0]));\n            }\n        };\n\n        let node = Node::new(id, endpoint.clone());\n        eprintln!(\"new cluster node:{}\", node);\n\n        nodes.insert(id, node);\n    }\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/control/src/import.rs#L142-L178","documentation":"Raised in build_nodes while parsing each entry of the --initial-cluster list. Each peer string must be '<NodeId>=<host>:<port>' with an optional obsolete second gRPC address; this error fires when the address part after '=' does not split into one or two host:port addresses (e.g. empty or extra commas).","triggerScenarios":"--initial-cluster peer strings like '1=addr1,addr2,addr3' (3 addresses) or '1=' (empty address list).","commonSituations":"Listing the whole cluster on one peer line instead of one entry per node; trailing commas creating an empty address; misunderstanding that each node needs its own peer entry.","solutions":["Provide at most two comma-separated addresses per peer: '<id>=<addr1>[,<addr2>]'","Split multi-node clusters into separate peer entries, one per node id","Remove trailing commas that create empty address tokens"],"exampleFix":"// before\n--initial-cluster 1=a:9191,b:9191,c:9191\n// after\n--initial-cluster 1=a:9191,b:9191 2=c:9191","handlingStrategy":"validation","validationCode":"for peer in initial_cluster {\n    if let Some(addrs) = peer.split('=').nth(1) {\n        let n = addrs.split(',').filter(|s| !s.is_empty()).count();\n        if !(1..=2).contains(&n) {\n            eprintln!(\"peer {} must have 1 or 2 addresses\", peer);\n        }\n    }\n}\n","typeGuard":null,"tryCatchPattern":"match build_nodes(initial_cluster) {\n    Err(e) if e.to_string().contains(\"require 1 or 2 addresses\") => eprintln!(\"one peer entry per node, max 2 addresses each\"),\n    other => other,\n}","preventionTips":["One peer entry per node id; never list the whole cluster on a single line","Strip trailing commas from generated peer strings","Generate initial-cluster args from templates rather than typing them"],"tags":["cli","parsing","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}