{"record":{"id":"df59f8da25bb2665","repo":"apache/pulsar","slug":"pulsarserviceurl-cannot-be-null","errorCode":null,"errorMessage":"pulsarServiceUrl cannot be null","messagePattern":"pulsarServiceUrl cannot be null","errorType":"exception","errorClass":"PulsarClientException","httpStatus":null,"severity":"critical","filePath":"pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/InstanceUtils.java","lineNumber":187,"sourceCode":"                    .serviceUrl(pulsarServiceUrl);\n            if (authConfig != null) {\n                if (isNotBlank(authConfig.getClientAuthenticationPlugin())\n                        && isNotBlank(authConfig.getClientAuthenticationParameters())) {\n                    clientBuilder.authentication(authConfig.getClientAuthenticationPlugin(),\n                            authConfig.getClientAuthenticationParameters());\n                }\n                clientBuilder.enableTls(authConfig.isUseTls());\n                clientBuilder.allowTlsInsecureConnection(authConfig.isTlsAllowInsecureConnection());\n                clientBuilder.enableTlsHostnameVerification(authConfig.isTlsHostnameVerificationEnable());\n                clientBuilder.tlsTrustCertsFilePath(authConfig.getTlsTrustCertsFilePath());\n            }\n            if (memoryLimit.isPresent()) {\n                clientBuilder.memoryLimit(memoryLimit.get(), SizeUnit.BYTES);\n            }\n            clientBuilder.ioThreads(Runtime.getRuntime().availableProcessors());\n            return clientBuilder;\n        }\n        throw new PulsarClientException(\"pulsarServiceUrl cannot be null\");\n    }\n\n    public static PulsarClient createPulsarClient(String pulsarServiceUrl, AuthenticationConfig authConfig)\n            throws PulsarClientException {\n        return createPulsarClient(pulsarServiceUrl, authConfig, Optional.empty());\n    }\n\n    public static PulsarClient createPulsarClient(String pulsarServiceUrl,\n                                                  AuthenticationConfig authConfig,\n                                                  Optional<Long> memoryLimit) throws PulsarClientException {\n        return createPulsarClientBuilder(pulsarServiceUrl, authConfig, memoryLimit).build();\n    }\n\n    public static PulsarAdmin createPulsarAdminClient(String pulsarWebServiceUrl, AuthenticationConfig authConfig)\n            throws PulsarClientException {\n        PulsarAdminBuilder pulsarAdminBuilder = null;\n        if (isNotBlank(pulsarWebServiceUrl)) {\n            pulsarAdminBuilder = PulsarAdmin.builder().serviceHttpUrl(pulsarWebServiceUrl);","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/InstanceUtils.java#L169-L205","documentation":"createPulsarClientBuilder builds a PulsarClient.Builder from a service URL, auth config, and optional memory limit. If the pulsarServiceUrl argument is null it cannot construct a client and throws PulsarClientException(\"pulsarServiceUrl cannot be null\") after applying any TLS/auth settings. This is a precondition check for missing instance configuration.","triggerScenarios":"createPulsarClient(null, authConfig, ...) is invoked — i.e. the instance config's pulsarServiceUrl was null, commonly when InstanceConfig was built without a service URL or it was not injected into the function environment.","commonSituations":"Missing `--pulsarServiceUrl` argument in the function instance launcher; incorrect KubernetesRuntime/ProcessRuntime config templates; hand-rolled InstanceConfig in tests omitting the service URL.","solutions":["Ensure the function instance is launched with a valid pulsarServiceUrl (e.g. pulsar://broker:6650) in the instance config/arguments.","If building InstanceConfig programmatically, set pulsarServiceUrl before calling createPulsarClient.","Check the worker's brokerClientConfiguration/serviceUrl settings that feed the per-instance config."],"exampleFix":"// before\nInstanceUtils.createPulsarClient(null, authConfig);\n// after\nInstanceUtils.createPulsarClient(\"pulsar://localhost:6650\", authConfig);","handlingStrategy":"validation","validationCode":"if (pulsarServiceUrl == null || pulsarServiceUrl.isBlank()) {\n    throw new IllegalArgumentException(\"pulsarServiceUrl must be set (e.g. pulsar://broker:6650)\");\n}","typeGuard":null,"tryCatchPattern":"try { client = InstanceUtils.createPulsarClient(url, authConfig); } catch (PulsarClientException e) { if (e.getMessage().contains(\"cannot be null\")) { throw new IllegalStateException(\"Instance config missing pulsarServiceUrl\", e); } throw e; }","preventionTips":["Always launch instances with --pulsarServiceUrl","Validate InstanceConfig fields before creating clients","Keep worker brokerClientConfiguration serviceUrl populated"],"tags":["pulsar-functions","pulsar-client","configuration","null-check"],"backgroundTag":"missing-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"}