{"record":{"id":"e835a57617ccda7f","repo":"dapr/dapr","slug":"address-for-node-s-not-found-in-raft-peers-s","errorCode":null,"errorMessage":"address for node %s not found in raft peers %s","messagePattern":"address for node (.+?) not found in raft peers (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/placement/peers/peers.go","lineNumber":35,"sourceCode":"\t\"fmt\"\n\n\t\"github.com/hashicorp/raft\"\n)\n\n// PeerInfo represents raft peer node information.\ntype PeerInfo struct {\n\tID      string\n\tAddress string\n}\n\nfunc AddressForID(id string, nodes []PeerInfo) (string, error) {\n\tfor _, node := range nodes {\n\t\tif node.ID == id {\n\t\t\treturn node.Address, nil\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"address for node %s not found in raft peers %s\", id, nodes)\n}\n\nfunc BootstrapConfig(peers []PeerInfo) (*raft.Configuration, error) {\n\traftConfig := &raft.Configuration{\n\t\tServers: make([]raft.Server, len(peers)),\n\t}\n\n\tfor i, p := range peers {\n\t\traftConfig.Servers[i] = raft.Server{\n\t\t\tID:      raft.ServerID(p.ID),\n\t\t\tAddress: raft.ServerAddress(p.Address),\n\t\t}\n\t}\n\n\treturn raftConfig, nil\n}\n","sourceCodeStart":17,"sourceCodeEnd":52,"githubUrl":"https://github.com/dapr/dapr/blob/74ad41702745709bb15fe2114ff693b8c59bc3cc/pkg/placement/peers/peers.go#L17-L52","documentation":"AddressForID (pkg/placement/peers/peers.go:28) scans the PeerInfo list parsed from --initial-cluster for the ID passed as --id (default dapr-placement-0); it is called from leadership.New at startup. If --id matches no entry key, the server cannot learn its own raft bind address and construction fails with this error. It also fires when the initial-cluster entries were parsed from malformed values that shifted the id=address pairing.","triggerScenarios":"--id=p1 while --initial-cluster keys are dapr-placement-0=...; --initial-cluster empty or malformed so the parsed peer list is empty; statefulset renamed but flags not updated; helm overrides changing replica count without regenerating initial-cluster.","commonSituations":"Hand-rolled multi-node placement deployments where id names drift from peer keys; local test harnesses assembling flags manually.","solutions":["Set --id to exactly one key present in --initial-cluster (keys are the id= prefixes).","Regenerate --initial-cluster covering every replica with consistent keys (the chart derives both from the statefulset).","Print/validate the parsed peers before start: each entry must be id=host:port with unique ids."],"exampleFix":"# before\n--id=p1 --initial-cluster=dapr-placement-0=127.0.0.1:8201   # p1 not a peer key\n# after\n--id=dapr-placement-0 --initial-cluster=dapr-placement-0=127.0.0.1:8201","handlingStrategy":"validation","validationCode":"// Validate flags before leadership.New (where AddressForID is called).\nfunc validatePlacementFlags(id string, peers []peers.PeerInfo) error {\n\tif id == \"\" {\n\t\treturn errors.New(\"--id is required\")\n\t}\n\tif len(peers) == 0 {\n\t\treturn errors.New(\"--initial-cluster parsed to zero peers\")\n\t}\n\tfor _, p := range peers {\n\t\tif p.ID == id {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"--id %q not found in --initial-cluster keys %v\", id, peerIDs(peers))\n}","typeGuard":"func hasPeer(id string, peers []peers.PeerInfo) bool {\n\tfor _, p := range peers {\n\t\tif p.ID == id {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}","tryCatchPattern":"leadershipSvc, err := leadership.New(leadership.Options{ID: id, Peers: peers, /* ... */})\nif err != nil {\n\t// startup config error: fix --id / --initial-cluster key mismatch; do not retry\n\tlog.Fatalf(\"placement identity not in raft peers: %v\", err)\n}","preventionTips":["Generate --id and --initial-cluster from the same source (statefulset name + ordinal) in templates.","Never scale replicas by editing flags alone — regenerate the whole initial-cluster list.","Add a container startup check that fails fast with a readable message when id is missing from peers."],"tags":["placement","raft","initial-cluster","configuration","startup"],"backgroundTag":null,"analyzedSha":"74ad41702745709bb15fe2114ff693b8c59bc3cc","analyzedAt":"2026-08-16T04:22:26.543Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}