{"record":{"id":"4ef5c4a28181c10b","repo":"apache/pulsar","slug":"no-scheme-url-configured-for-broker-brokerid","errorCode":null,"errorMessage":"No ${scheme} URL configured for broker ${brokerId}","messagePattern":"No (.+?) URL configured for broker (.+?)","errorType":"http","errorClass":"WebApplicationException","httpStatus":412,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/LookupResult.java","lineNumber":289,"sourceCode":"    }\n\n    private URI toRedirectUriInternal(URI requestUri, boolean authoritativeRedirect,\n                                      boolean injectListenerNameQueryParam) {\n        boolean requireHttps = \"https\".equalsIgnoreCase(requestUri.getScheme());\n        String webServiceUrl = requireHttps ? lookupData.getHttpUrlTls() : lookupData.getHttpUrl();\n        if (webServiceUrl == null) {\n            // Preserve the legacy 412 error semantics when the redirect target broker has no URL\n            // configured for the requested scheme.\n            String scheme = requireHttps ? \"https\" : \"http\";\n            StringBuilder entity = new StringBuilder()\n                    .append(\"No \").append(scheme).append(\" URL configured for broker \")\n                    .append(lookupData.getBrokerId());\n            if (StringUtils.isNotBlank(webServiceListenerName)) {\n                entity.append(\" on web service listener `\").append(webServiceListenerName).append(\"`\");\n            } else if (StringUtils.isNotBlank(brokerServiceListenerName)) {\n                entity.append(\" on listener `\").append(brokerServiceListenerName).append(\"`\");\n            }\n            throw new WebApplicationException(Response.status(Response.Status.PRECONDITION_FAILED)\n                    .entity(entity.toString())\n                    .build());\n        }\n        URI webServiceUri = URI.create(webServiceUrl);\n        UriBuilder uriBuilder =\n                UriBuilder.fromUri(requestUri) // use the path and query parameters from the request URI\n                        .scheme(webServiceUri.getScheme()) // use the schema from the lookup result\n                        .host(webServiceUri.getHost())  // use the host from the lookup result\n                        .port(webServiceUri.getPort()); // use the port from the lookup result\n        if (isRedirect()) {\n            // pass the authoritative parameter only when the type is redirect\n            uriBuilder.replaceQueryParam(\"authoritative\", authoritativeRedirect);\n        } else {\n            // remove the parameter when the type is not redirect\n            uriBuilder.replaceQueryParam(\"authoritative\");\n        }\n        // Only set the listenerName query parameter on topic-lookup redirects. The original lookup\n        // request can carry it either as a query parameter or as a header; the latter does not","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/LookupResult.java#L271-L307","documentation":"LookupResult.toRedirectUriInternal builds an HTTP redirect to another broker using the target broker's HTTP/HTTPS web-service URL. If the target broker's lookup data has no URL for the requested scheme (request was https but only an http URL is advertised, or vice versa), it throws WebApplicationException with HTTP 412 PRECONDITION_FAILED and message 'No <scheme> URL configured for broker <id>'.","triggerScenarios":"A REST lookup/admin redirect occurs where the incoming request scheme is https but the redirect target's advertisedListeners/webServiceUrl lacks a TLS URL (or the request is http but only TLS URL exists), including when a specific advertised listener was selected.","commonSituations":"Broker advertises only non-TLS listeners while clients use https (or the reverse); advertisedListeners misconfigured without the right scheme; TLS configured on the proxy but not on the redirect-target broker; listenerName resolving to a listener without the required URL.","solutions":["Configure the target broker's advertisedListeners/webServiceUrl so both http and https URLs are advertised (add TLS listener with advertisedListeners=...,tls... and webServiceUrlTls).","Match the client scheme to what the target broker actually advertises (use http if no TLS URL is configured).","Fix the advertised listener name in the request so it resolves to a listener that has the requested scheme's URL.","Handle the 412 PRECONDITION_FAILED response in the client by falling back to direct lookup on the advertised URL that does exist."],"exampleFix":"# before (broker.conf)\nadvertisedListeners=http:localhost:8080\n# after\nadvertisedListeners=http:localhost:8080,https:localhost:8443\nwebServiceUrl=http://localhost:8080\nwebServiceUrlTls=https://localhost:8443","handlingStrategy":"try-catch","validationCode":"boolean https = \"https\".equalsIgnoreCase(requestUri.getScheme());\nString url = https ? lookupData.getHttpUrlTls() : lookupData.getHttpUrl();\nif (url == null) { /* target cannot serve this scheme; pick another broker or fail fast */ }","typeGuard":"boolean canRedirect(LookupData d, boolean https) {\n    return d != null && (https ? d.getHttpUrlTls() != null : d.getHttpUrl() != null);\n}","tryCatchPattern":"try {\n    URI redirect = lookupResult.toRedirectUri(requestUri);\n    return Response.temporaryRedirect(redirect).build();\n} catch (WebApplicationException e) {\n    if (e.getResponse().getStatus() == 412) {\n        return Response.status(Response.Status.SERVICE_UNAVAILABLE)\n            .entity(e.getResponse().getEntity()).build();\n    }\n    throw e;\n}","preventionTips":["Advertise both http and https web-service URLs (webServiceUrl + webServiceUrlTls) on every broker.","Keep client scheme consistent with advertised listeners across the cluster.","Include the TLS listener in advertisedListeners when terminating https anywhere in the path.","Monitor for 412 responses on lookup endpoints as a config-drift signal."],"tags":["http-redirect","tls","lookup","configuration"],"backgroundTag":"missing-tls-url-config","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}