{"record":{"id":"686ff7ce77587e0d","repo":"pinpoint-apm/pinpoint","slug":"webhook-url-port-is-not-valid","errorCode":null,"errorMessage":"Webhook URL port is not valid","messagePattern":"Webhook URL port is not valid","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons-server/src/main/java/com/navercorp/pinpoint/common/server/webhook/WebhookUrlValidator.java","lineNumber":133,"sourceCode":"        }\n    }\n\n    private static void validateAuthority(URI uri) {\n        if (uri.getHost() == null || uri.getHost().isBlank()) {\n            throw new IllegalArgumentException(\"Webhook URL host is required\");\n        }\n        if (isBlockedHostLiteral(uri.getHost())) {\n            throw new IllegalArgumentException(\"Webhook URL host is not allowed\");\n        }\n        if (uri.getRawUserInfo() != null) {\n            throw new IllegalArgumentException(\"Webhook URL user info is not allowed\");\n        }\n        if (uri.getRawFragment() != null) {\n            throw new IllegalArgumentException(\"Webhook URL fragment is not allowed\");\n        }\n        int port = uri.getPort();\n        if (port == -1 && hasExplicitPort(uri)) {\n            throw new IllegalArgumentException(\"Webhook URL port is not valid\");\n        }\n        if (port == 0 || port > MAX_PORT) {\n            throw new IllegalArgumentException(\"Webhook URL port is not allowed\");\n        }\n    }\n\n    private static boolean hasExplicitPort(URI uri) {\n        String rawAuthority = uri.getRawAuthority();\n        if (rawAuthority == null || rawAuthority.isEmpty()) {\n            return false;\n        }\n\n        int hostStartIndex = rawAuthority.lastIndexOf('@') + 1;\n        if (rawAuthority.charAt(hostStartIndex) == '[') {\n            int hostEndIndex = rawAuthority.indexOf(']', hostStartIndex);\n            return hostEndIndex >= 0\n                    && hostEndIndex + 1 < rawAuthority.length()\n                    && rawAuthority.charAt(hostEndIndex + 1) == ':';","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-server/src/main/java/com/navercorp/pinpoint/common/server/webhook/WebhookUrlValidator.java#L115-L151","documentation":"WebhookUrlValidator.validateAuthority throws IllegalArgumentException when the port is unusable: an explicit ':' port that fails to parse (getPort()==-1 while hasExplicitPort is true), port 0, or a port above MAX_PORT (65535). The validator rejects ambiguous or out-of-range ports.","triggerScenarios":"URLs like 'https://example.com:/hook' (colon with no number, or non-numeric), 'http://example.com:0/', 'http://example.com:99999/' passed to validateSyntax/uri.","commonSituations":"Typo leaving a dangling colon after the host; config placeholder not substituted (e.g. :${PORT} or :0); hand-written port exceeding 65535.","solutions":["Fix or remove the port: use 'https://example.com/hook' for default ports or a valid number 1-65535","Substitute config placeholders (e.g. :${PORT}) with the actual port number before validating","Verify the port is an integer within 1-65535"],"exampleFix":"// before\nvalidator.validateSyntax(\"https://example.com:${PORT}/webhook\");\n// after\nvalidator.validateSyntax(\"https://example.com:8443/webhook\");","handlingStrategy":"validation","validationCode":"java.net.URI u = java.net.URI.create(url); int p = u.getPort(); if (p == 0 || p > 65535 || (p == -1 && url.matches(\".*:[^/].*\"))) reject(url);","typeGuard":"boolean hasValidPort(java.net.URI uri) { int p = uri.getPort(); return p == -1 || (p > 0 && p <= 65535); }","tryCatchPattern":"try { WebhookUrlValidator.validateSyntax(url); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"port\")) { reject or fix port; } }","preventionTips":["Resolve config placeholders like :${PORT} before validating","Omit the port entirely for default ports (80/443)","Validate port range 1-65535 at the config boundary"],"tags":["java","webhook","url","port"],"backgroundTag":"value-out-of-range","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}