{"record":{"id":"244d8b64768242e8","repo":"apache/pulsar","slug":"failed-to-update-url","errorCode":null,"errorMessage":"Failed to update url ","messagePattern":"Failed to update url ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java","lineNumber":1790,"sourceCode":"\n    public CompletableFuture<ClientCnx> getConnection(final String topic, final String url) {\n        TopicName topicName = TopicName.get(topic);\n        return getLookup(url).getBroker(topicName)\n                .thenCompose(lookupResult -> getConnection(lookupResult.getLogicalAddress(),\n                        lookupResult.getPhysicalAddress(), cnxPool.genRandomKeyToSelectCon()));\n    }\n\n    public LookupService getLookup(String serviceUrl) {\n        return urlLookupMap.computeIfAbsent(serviceUrl, url -> {\n            if (isClosed()) {\n                throw new IllegalStateException(\"Pulsar client has been closed, can not build LookupService when\"\n                        + \" calling get lookup with an url\");\n            }\n            try {\n                return createLookup(serviceUrl);\n            } catch (PulsarClientException e) {\n                log.warn().attr(\"service\", url).exceptionMessage(e).log(\"Failed to update url to lookup service\");\n                throw new IllegalStateException(\"Failed to update url \" + url);\n            }\n        });\n    }\n\n    public CompletableFuture<ClientCnx> getConnectionToServiceUrl() {\n        if (!lookup.isBinaryProtoLookupService()) {\n            return FutureUtil.failedFuture(new PulsarClientException.InvalidServiceURL(\n                    \"Can't get client connection to HTTP service URL\", null));\n        }\n        InetSocketAddress address = lookup.resolveHost();\n        return getConnection(address, address, cnxPool.genRandomKeyToSelectCon());\n    }\n\n    /**\n     * Open a connection to the proxy and ask it to pair the connection to any broker it selects\n     * (an empty proxyToBrokerUrl). Used for control-plane operations that aren't tied to a specific\n     * broker (e.g. scalable-topic subscribe/namespace-watch) when connecting through a proxy.\n     */","sourceCodeStart":1772,"sourceCodeEnd":1808,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java#L1772-L1808","documentation":"When getLookup(serviceUrl) cannot create a LookupService for the given URL (createLookup throws PulsarClientException), the client logs a warning ('Failed to update url to lookup service') and rethrows as IllegalStateException('Failed to update url ' + url). It means the URL could not be mapped to any usable lookup service. The message is truncated by exception formatting; the URL identifies the failing endpoint.","triggerScenarios":"Calling getLookup(url) with a malformed or unsupported service URL scheme, or with a URL for which createLookup cannot construct a binary/HTTP lookup service (bad scheme, missing http client, invalid host).","commonSituations":"Passing an http:// URL to a client built for the binary protocol (or vice versa); typos in the scheme (pulsar:// vs pulsar+ssl:// vs http://); URLs loaded from a broker discovery list containing unsupported schemes.","solutions":["Fix the service URL scheme/shape to one the client supports (pulsar://, pulsar+ssl://, or http/https when HTTP lookup is available).","Check the preceding WARN log 'Failed to update url to lookup service' for the underlying PulsarClientException cause.","Validate URLs from external/discovery configuration before passing them to getLookup."],"exampleFix":"// before\nclient.getLookup(\"htt://broker:8080\"); // bad scheme\n// after\nclient.getLookup(\"pulsar://broker:6650\");","handlingStrategy":"validation","validationCode":"if (!url.startsWith(\"pulsar://\") && !url.startsWith(\"pulsar+ssl://\")\n        && !url.startsWith(\"http://\") && !url.startsWith(\"https://\")) {\n    throw new IllegalArgumentException(\"Unsupported lookup service URL scheme: \" + url);\n}","typeGuard":null,"tryCatchPattern":"try {\n    LookupService ls = client.getLookup(url);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Failed to update url\")) {\n        log.warn(\"Cannot map {} to a lookup service\", url, e);\n    } else throw e;\n}","preventionTips":["Validate URL schemes coming from discovery/config before calling getLookup.","Check the WARN log line for the underlying PulsarClientException cause when a URL fails.","Keep the scheme consistent with the client's protocol (binary pulsar:// vs HTTP lookup)."],"tags":["pulsar","lookup","invalid-url","illegal-state"],"backgroundTag":"invalid-service-url","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"}