{"record":{"id":"cf1ad82da3a64350","repo":"apache/pulsar","slug":"cannot-find-namespaceisolationpolicy-policyname","errorCode":null,"errorMessage":"Cannot find NamespaceIsolationPolicy ${policyName} for cluster ${cluster}","messagePattern":"Cannot find NamespaceIsolationPolicy (.+?) for cluster (.+?)","errorType":"http","errorClass":"RestException","httpStatus":404,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java","lineNumber":627,"sourceCode":"                    content = @Content(schema = @Schema(implementation = NamespaceIsolationDataImpl.class))),\n            @ApiResponse(responseCode = \"403\", description = \"Don't have admin permission.\"),\n            @ApiResponse(responseCode = \"404\", description = \"Policy doesn't exist.\"),\n            @ApiResponse(responseCode = \"412\", description = \"Cluster doesn't exist.\"),\n            @ApiResponse(responseCode = \"500\", description = \"Internal server error.\")\n    })\n    public void getNamespaceIsolationPolicy(\n        @Suspended AsyncResponse asyncResponse,\n        @Parameter(description = \"The cluster name\", required = true) @PathParam(\"cluster\") String cluster,\n        @Parameter(description = \"The name of the namespace isolation policy\", required = true)\n        @PathParam(\"policyName\") String policyName\n    ) {\n        validateBothSuperuserAndClusterPolicyOperation(cluster, PolicyName.NAMESPACE_ISOLATION, PolicyOperation.READ)\n                .thenCompose(__ -> validateClusterExistAsync(cluster, Status.PRECONDITION_FAILED))\n                .thenCompose(__ -> internalGetNamespaceIsolationPolicies(cluster))\n                .thenAccept(policies -> {\n                    // construct the response to Namespace isolation data map\n                    if (!policies.containsKey(policyName)) {\n                        throw new RestException(Status.NOT_FOUND,\n                                \"Cannot find NamespaceIsolationPolicy \" + policyName + \" for cluster \" + cluster);\n                    }\n                    asyncResponse.resume(policies.get(policyName));\n                }).exceptionally(ex -> {\n                    log.error()\n                            .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    @GET\n    @Path(\"/{cluster}/namespaceIsolationPolicies/brokers\")\n    @Operation(\n        summary = \"Get list of brokers with namespace-isolation policies attached to them.\",\n        description = \"This operation requires Pulsar superuser privileges.\"","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java#L609-L645","documentation":"HTTP 404 (NOT_FOUND) thrown by getNamespaceIsolationPolicy when the cluster exists and has isolation policies, but no policy with the requested policyName is present in that map. The check is policies.containsKey(policyName) after loading all policies for the cluster.","triggerScenarios":"GET /admin/v3/clusters/{cluster}/namespaceIsolationPolicies/{policyName} with a policy name that was never created or already deleted; case mismatch in policy name; querying a policy defined on a different cluster.","commonSituations":"Renamed policies in newer config management code; per-cluster policy sets where the name exists only on one cluster; typos in policy name in dashboards/automation.","solutions":["List available policies with GET /admin/v3/clusters/{cluster}/namespaceIsolationPolicies and use an exact existing name.","Create the policy first with POST .../namespaceIsolationPolicies/{policyName} if it should exist.","Check name spelling and case-sensitivity against the stored policy."],"exampleFix":"// before\nNamespaceIsolationData d = admin.namespaces().getNamespaceIsolationPolicy(\"c1\", \"prod_only\"); // 404\n// after\nMap<String, NamespaceIsolationData> all = admin.namespaces().getNamespaceIsolationPolicies(\"c1\");\nif (all.containsKey(\"prod_only\")) {\n    NamespaceIsolationData d = all.get(\"prod_only\");\n}","handlingStrategy":"validation","validationCode":"Map<String, NamespaceIsolationData> all =\n        admin.namespaces().getNamespaceIsolationPolicies(cluster); // may 404 -> empty\nif (!all.containsKey(policyName)) {\n    throw new IllegalArgumentException(\"Policy \" + policyName + \" not in \" + all.keySet());\n}\nNamespaceIsolationData d = admin.namespaces().getNamespaceIsolationPolicy(cluster, policyName);","typeGuard":null,"tryCatchPattern":"try {\n    admin.namespaces().getNamespaceIsolationPolicy(cluster, policyName);\n} catch (PulsarAdminException.NotFoundException e) {\n    // list existing policies and pick/create the correct name\n}","preventionTips":["Fetch the policy map first and use exact keys from it.","Watch case-sensitivity in policy names; standardize naming conventions.","Create policies per cluster where needed rather than assuming global policy names."],"tags":["rest-api","not-found","isolation-policy","lookup"],"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"}