{"record":{"id":"526eaf9b118f7a50","repo":"apache/cassandra","slug":"the-current-host-must-be-part-of-the-repair","errorCode":null,"errorMessage":"The current host must be part of the repair","messagePattern":"The current host must be part of the repair","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/ActiveRepairService.java","lineNumber":649,"sourceCode":"        else if (hosts != null && !hosts.isEmpty())\n        {\n            Set<InetAddressAndPort> specifiedHost = new HashSet<>();\n            for (final String host : hosts)\n            {\n                try\n                {\n                    final InetAddressAndPort endpoint = InetAddressAndPort.getByName(host.trim());\n                    if (endpoint.equals(ctx.broadcastAddressAndPort()) || neighbors.endpoints().contains(endpoint))\n                        specifiedHost.add(endpoint);\n                }\n                catch (UnknownHostException e)\n                {\n                    throw new IllegalArgumentException(\"Unknown host specified \" + host, e);\n                }\n            }\n\n            if (!specifiedHost.contains(ctx.broadcastAddressAndPort()))\n                throw new IllegalArgumentException(\"The current host must be part of the repair\");\n\n            if (specifiedHost.size() <= 1)\n            {\n                String msg = \"Specified hosts %s do not share range %s needed for repair. Either restrict repair ranges \" +\n                             \"with -st/-et options, or specify one of the neighbors that share this range with \" +\n                             \"this node: %s.\";\n                throw new IllegalArgumentException(String.format(msg, hosts, toRepair, neighbors));\n            }\n\n            specifiedHost.remove(ctx.broadcastAddressAndPort());\n            return neighbors.keep(specifiedHost);\n        }\n\n        return neighbors;\n    }\n\n    /**\n     * we only want to set repairedAt for incremental repairs including all replicas for a token range. For non-global","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/ActiveRepairService.java#L631-L667","documentation":"filterNeighbors requires that the local (broadcast) address be included in the explicitly specified host list for a sub-range repair; otherwise the operation is rejected. The repair must run on this node and it must know it participates in the specified replica set.","triggerScenarios":"Calling nodetool repair -hosts h1,h2 (with -st/-et) where the node receiving the command is not listed among the hosts.","commonSituations":"Operators running sub-range repairs from a coordinator node and forgetting to include that node's own address in the -hosts list.","solutions":["Add the local node's address to the -hosts list","Run the repair command on a node that is part of the specified host set"],"exampleFix":"// before\nnodetool repair keyspace1 -hosts 10.0.0.2,10.0.0.3  # issued on 10.0.0.1\n// after\nnodetool repair keyspace1 -hosts 10.0.0.1,10.0.0.2,10.0.0.3","handlingStrategy":"validation","validationCode":"// ensure local node's broadcast address is in the host list\nInetAddressAndPort local = FBUtilities.getBroadcastAddressAndPort();\nif (!hostList.contains(local)) throw new IllegalArgumentException(\"local node must be in -hosts\");","typeGuard":null,"tryCatchPattern":"try { repair(...); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"The current host must be part of the repair\")) addSelfToHosts();\n    throw e;\n}","preventionTips":["When scripting sub-range repairs with -hosts, always prepend the issuing node's broadcast address"],"tags":["repair","hosts","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}