{"record":{"id":"d34a0a299e196f05","repo":"apache/pulsar","slug":"invalid-pulsar-service-servicename-servicei","errorCode":null,"errorMessage":"Invalid pulsar service : ${serviceName}+${serviceInfos}","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":225,"sourceCode":"        } else {\n            if (serviceInfos.length == 0) {\n                return serviceName;\n            } else {\n                return serviceName + \"+\" + StringUtils.join(serviceInfos, '+');\n            }\n        }\n    }\n\n    private static int getServicePort(String serviceName, String[] serviceInfos) {\n        int port;\n        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","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-common/src/main/java/org/apache/pulsar/common/net/ServiceURI.java#L207-L243","documentation":"For a BINARY ('pulsar') service, ServiceURI expects either no service-info suffix (plain, default binary port 6650) or exactly the single suffix 'ssl' (TLS binary port 6651). Any other combination of serviceInfos appended after '+' (e.g. 'pulsar+foo', 'pulsar+ssl+extra') is rejected with 'Invalid pulsar service : <serviceName>+<serviceInfos>'.","triggerScenarios":"ServiceURI.create('pulsar+foo://host:6650') or 'pulsar+ssl+extra://...' — a service name that is 'pulsar'/'binary' combined with a serviceInfo other than 'ssl' (case-insensitive) or more than one info.","commonSituations":"Typos in the scheme such as 'pulsar+tls' (correct is 'pulsar+ssl'); accidentally duplicating the suffix ('pulsar+ssl+ssl'); copying an http-style URI scheme onto a binary port.","solutions":["Use 'pulsar://host:6650' for plain binary or 'pulsar+ssl://host:6651' for TLS — no other suffixes are valid.","If you meant TLS, replace '+tls' with '+ssl'.","Remove extra '+'-separated segments from the URI scheme.","Use 'http://' or 'https://' service URIs if you intended the HTTP service instead."],"exampleFix":"// before\nServiceURI u = ServiceURI.create(\"pulsar+tls://broker:6651\");\n// after\nServiceURI u = ServiceURI.create(\"pulsar+ssl://broker:6651\");","handlingStrategy":"validation","validationCode":"static final Set<String> VALID_BINARY_INFOS = Set.of(\"ssl\");\nstatic void validateServiceUri(String scheme) {\n    String[] parts = scheme.split(\"\\\\+\");\n    String service = parts[0];\n    String[] infos = Arrays.copyOfRange(parts, 1, parts.length);\n    if (List.of(\"pulsar\",\"broker\").contains(service)\n        && !(infos.length == 0 || (infos.length == 1 && infos[0].equalsIgnoreCase(\"ssl\")))) {\n        throw new IllegalArgumentException(\"Invalid pulsar service : \" + scheme);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    ServiceURI uri = ServiceURI.create(serviceUrl);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid pulsar service\")) {\n        // scheme suffix wrong: only pulsar:// or pulsar+ssl:// allowed for binary service\n    }\n    throw e;\n}","preventionTips":["Only use the documented schemes: pulsar, pulsar+ssl, http, https, broker, broker+ssl.","Never write '+tls' — the accepted suffix is '+ssl'.","Keep exactly one '+'-separated info segment at most."],"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"}