{"record":{"id":"45dac66d419f73a1","repo":"apache/pulsar","slug":"cluster-cluster-does-not-exist-45dac6","errorCode":null,"errorMessage":"Cluster ${cluster} does not exist.","messagePattern":"Cluster (.+?) does not exist\\.","errorType":"http","errorClass":"RestException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java","lineNumber":583,"sourceCode":"                            .attr(\"cluster\", cluster)\n                            .exception(ex)\n                            .log(\"Failed to get namespace isolation policies\");\n                    resumeAsyncResponseExceptionally(asyncResponse, ex);\n                    return null;\n                });\n    }\n\n    /**\n     * Verify that the cluster exists.\n     * For compatibility to avoid breaking changes, we can specify a REST status code when it doesn't exist.\n     * @param cluster Cluster name\n     * @param notExistStatus REST status code\n     */\n    private CompletableFuture<Void> validateClusterExistAsync(String cluster, Status notExistStatus) {\n        return clusterResources().clusterExistsAsync(cluster)\n                .thenAccept(clusterExist -> {\n                    if (!clusterExist) {\n                        throw new RestException(notExistStatus, \"Cluster \" + cluster + \" does not exist.\");\n                    }\n                });\n    }\n\n    private CompletableFuture<Map<String, NamespaceIsolationDataImpl>> internalGetNamespaceIsolationPolicies(\n            String cluster) {\n            return namespaceIsolationPolicies().getIsolationDataPoliciesAsync(cluster)\n                    .thenApply(namespaceIsolationPolicies -> {\n                        if (!namespaceIsolationPolicies.isPresent()) {\n                            throw new RestException(Status.NOT_FOUND,\n                                    \"NamespaceIsolationPolicies for cluster \" + cluster + \" does not exist\");\n                        }\n                        return namespaceIsolationPolicies.get().getPolicies();\n                    });\n    }\n\n    @GET\n    @Path(\"/{cluster}/namespaceIsolationPolicies/{policyName}\")","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java#L565-L601","documentation":"HTTP error (status depends on the caller's notExistStatus parameter, typically 412 PRECONDITION_FAILED) thrown by validateClusterExistAsync when the target cluster does not exist in metadata. It guards all namespace-isolation and broker-isolation endpoints before they read or write cluster-scoped data. Called by getNamespaceIsolationPolicies, getNamespaceIsolationPolicy, broker listing, and set/delete isolation policy.","triggerScenarios":"GET/POST/DELETE on /admin/v3/clusters/{cluster}/namespaceIsolationPolicies (or /brokersWithNamespaceIsolationPolicy) with a cluster name not present in metadata; typos in cluster name; querying isolation policies of a decommissioned cluster.","commonSituations":"Automation hitting a wrong-environment cluster name; running isolation-policy scripts before cluster creation; stale config after a cluster was renamed.","solutions":["Verify the cluster exists: GET /admin/v3/clusters/{cluster} (or GET /admin/v3/clusters to list all) and fix the name.","Create the missing cluster first with POST /admin/v3/clusters/{cluster} if it is genuinely needed.","Use the exact, case-sensitive cluster name as registered (e.g. \"us-east\" not \"US-East\")."],"exampleFix":"// before\nadmin.namespaces().getNamespaceIsolationPolicies(\"east-1\"); // fails if not created\n// after\nif (admin.clusters().getClusters().contains(\"east-1\")) {\n    admin.namespaces().getNamespaceIsolationPolicies(\"east-1\");\n} else {\n    throw new IllegalStateException(\"Cluster east-1 must be created first\");\n}","handlingStrategy":"validation","validationCode":"List<String> clusters = admin.clusters().getClusters();\nif (!clusters.contains(cluster)) {\n    throw new IllegalArgumentException(\"Cluster \" + cluster + \" does not exist; existing: \" + clusters);\n}\nadmin.namespaces().getNamespaceIsolationPolicies(cluster);","typeGuard":null,"tryCatchPattern":"try {\n    admin.namespaces().getNamespaceIsolationPolicies(cluster);\n} catch (PulsarAdminException e) {\n    if (e.getStatusCode() == 412) {\n        // cluster does not exist: create it or correct the name\n    }\n    throw e;\n}","preventionTips":["Verify cluster names against GET /admin/v3/clusters before calling isolation endpoints.","Use shared, typed constants for cluster names rather than free-form strings.","Create clusters before running per-cluster policy/broker tooling."],"tags":["rest-api","cluster-not-found","precondition-failed","validation"],"backgroundTag":"referenced-resource-not-found","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}