{"record":{"id":"f5bcbbaf3d3cc9a4","repo":"apache/pulsar","slug":"invalid-pulsar-service-servicename","errorCode":null,"errorMessage":"Invalid pulsar service : ${serviceName}","messagePattern":"Invalid pulsar service : (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-common/src/main/java/org/apache/pulsar/common/net/ServiceURI.java","lineNumber":236,"sourceCode":"        switch (serviceName.toLowerCase()) {\n            case BINARY_SERVICE:\n                if (serviceInfos.length == 0) {\n                    port = BINARY_PORT;\n                } else if (serviceInfos.length == 1 && serviceInfos[0].equalsIgnoreCase(SSL_SERVICE)) {\n                    port = BINARY_TLS_PORT;\n                } else {\n                    throw new IllegalArgumentException(\"Invalid pulsar service : \" + serviceName + \"+\"\n                        + Arrays.toString(serviceInfos));\n                }\n                break;\n            case HTTP_SERVICE:\n                port = HTTP_PORT;\n                break;\n            case HTTPS_SERVICE:\n                port = HTTPS_PORT;\n                break;\n            default:\n                throw new IllegalArgumentException(\"Invalid pulsar service : \" + serviceName);\n        }\n        return port;\n    }\n\n    /**\n     * Create a new URI from the service URI which only specifies one of the hosts.\n     * @return a pulsar service URI with a single host specified\n     */\n    public String selectOne() {\n        StringBuilder sb = new StringBuilder();\n        if (serviceName != null) {\n            sb.append(serviceName);\n\n            for (int i = 0; i < serviceInfos.length; i++) {\n                sb.append('+').append(serviceInfos[i]);\n            }\n            sb.append(\"://\");\n        }","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-common/src/main/java/org/apache/pulsar/common/net/ServiceURI.java#L218-L254","documentation":"ServiceURI recognizes service names: binary ('pulsar'), 'http', and 'https' (plus broker/http/https variants per getServicePort's switch). If the scheme's service name is none of these, getServicePort's default branch throws 'Invalid pulsar service : <serviceName>'. This is a scheme typo or an unsupported scheme string.","triggerScenarios":"ServiceURI.create('pulsarx://host:6650'), 'PULSAR2://...', or a custom scheme that ServiceURI does not map to a known service; the service name is derived from the text before '+' in the URI scheme.","commonSituations":"Typo'd schemes ('pulsers://', 'pulsar-ssl://'); using 'grpc://' or another scheme unsupported by this parser; casing handled via equalsIgnoreCase so case is not the issue.","solutions":["Correct the scheme to one of: pulsar, pulsar+ssl, http, https, broker, broker+ssl (match the exact supported set).","If you intended TLS binary service use 'pulsar+ssl', not 'pulsar-ssl' or 'pulsars'.","Check the serviceUrl against the broker's advertised serviceUrl/advertisedListeners configuration."],"exampleFix":"// before\nServiceURI u = ServiceURI.create(\"pulsars://broker:6651\");\n// after\nServiceURI u = ServiceURI.create(\"pulsar+ssl://broker:6651\");","handlingStrategy":"validation","validationCode":"static final Set<String> VALID_SERVICES = Set.of(\"pulsar\",\"broker\",\"http\",\"https\");\nstatic void assertKnownService(String serviceUrl) {\n    String scheme = serviceUrl.substring(0, serviceUrl.indexOf(\":\"));\n    String service = scheme.split(\"\\\\+\")[0];\n    if (!VALID_SERVICES.contains(service.toLowerCase())) {\n        throw new IllegalArgumentException(\"Invalid pulsar service : \" + service);\n    }\n}","typeGuard":"static boolean isKnownServiceName(String service) {\n    return Set.of(\"pulsar\",\"broker\",\"http\",\"https\").contains(service.toLowerCase());\n}","tryCatchPattern":"try {\n    ServiceURI uri = ServiceURI.create(serviceUrl);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid pulsar service\")) {\n        // unknown scheme name: fix typo to pulsar/pulsar+ssl/http/https\n    }\n    throw e;\n}","preventionTips":["Copy serviceUrl schemes from the broker's advertisedListeners config, not by hand.","Check spelling of the scheme; casing is tolerated but spelling is not.","For TLS binary use 'pulsar+ssl' (not 'pulsars' or 'pulsar-ssl')."],"tags":["uri","config","service-uri"],"backgroundTag":"invalid-service-uri","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"}