{"record":{"id":"df16b96da5d09e7d","repo":"apache/seatunnel","slug":"invalid-endpoint-endpoint-expected-format-hos","errorCode":null,"errorMessage":"Invalid endpoint: ${endpoint}, expected format host:port","messagePattern":"Invalid endpoint: (.+?), expected format host:port","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/config/EdgeTransportEndpoints.java","lineNumber":49,"sourceCode":"    public static void validateFormat(String endpoint) {\n        parseHostAndPort(endpoint);\n    }\n\n    /** Resolves {@code endpoint} to a socket address for {@link EdgeTransportClient}. */\n    public static InetSocketAddress toSocketAddress(String endpoint) {\n        HostPort hostPort = parseHostAndPort(endpoint);\n        return new InetSocketAddress(hostPort.host, hostPort.port);\n    }\n\n    private static HostPort parseHostAndPort(String endpoint) {\n        Objects.requireNonNull(endpoint, \"endpoint\");\n        String trimmed = endpoint.trim();\n        if (trimmed.isEmpty()) {\n            throw new IllegalArgumentException(\"transport.endpoint must be non-empty.\");\n        }\n        int separatorIndex = trimmed.lastIndexOf(':');\n        if (separatorIndex <= 0 || separatorIndex >= trimmed.length() - 1) {\n            throw new IllegalArgumentException(\n                    \"Invalid endpoint: \" + endpoint + \", expected format host:port\");\n        }\n        String host = trimmed.substring(0, separatorIndex);\n        String portText = trimmed.substring(separatorIndex + 1);\n        int port;\n        try {\n            port = Integer.parseInt(portText);\n        } catch (NumberFormatException parseException) {\n            throw new IllegalArgumentException(\n                    \"Invalid endpoint port in endpoint: \" + endpoint, parseException);\n        }\n        if (port < 1 || port > 65535) {\n            throw new IllegalArgumentException(\n                    \"transport.endpoint port must be a valid TCP port (1-65535), got: \" + port);\n        }\n        return new HostPort(host, port);\n    }\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/config/EdgeTransportEndpoints.java#L31-L67","documentation":"parseHostAndPort locates the last ':' in the trimmed endpoint and requires it to have a character on both sides (separatorIndex > 0 and < length-1). If the colon is missing, leading, or trailing, it throws IllegalArgumentException with the offending endpoint and the expected host:port format.","triggerScenarios":"Calling EdgeTransportEndpoints.hostPort/validateFormat with endpoints like \"localhost\", \":8080\", \"host:\", or \"host:port:extra\" where lastIndexOf(':') fails the position checks.","commonSituations":"Forgetting the port in a copied URL; including a scheme like \"http://host:8080\" is fine but \"tcp:host\" style prefixes without colon placement break; trailing colons from template concatenation; IPv6 unbracketed literals in exotic cases.","solutions":["Write the endpoint as host:port with both parts non-empty, e.g. \"10.0.0.5:5800\".","Strip any protocol scheme or path so only host:port remains.","If port is implied, state it explicitly; the parser does not apply defaults.","For hostnames, confirm the string has exactly the intended single colon separating host and numeric port."],"exampleFix":"// before\ntransport.endpoint = \"localhost\"\n\n// after\ntransport.endpoint = \"localhost:5800\"","handlingStrategy":"validation","validationCode":"String endpoint = cfg.getString(\"transport.endpoint\").trim();\nint idx = endpoint.lastIndexOf(':');\nif (idx <= 0 || idx >= endpoint.length() - 1) {\n    throw new IllegalStateException(\"transport.endpoint must be host:port, got: \" + endpoint);\n}","typeGuard":"boolean looksLikeHostPort(String s) {\n    String t = s == null ? \"\" : s.trim();\n    int i = t.lastIndexOf(':');\n    return i > 0 && i < t.length() - 1;\n}","tryCatchPattern":"try {\n    EdgeTransportEndpoints.validateFormat(endpoint);\n} catch (IllegalArgumentException e) {\n    LOG.error(\"Endpoint must be in host:port form: \" + endpoint, e);\n    throw e;\n}","preventionTips":["Always include an explicit numeric port when writing endpoints.","Strip URL schemes and paths before assigning values to transport.endpoint.","Add a lint rule that endpoints match ^[^:]+:[0-9]+$.","Quote endpoint strings in HOCON to avoid parser quirks."],"tags":["config","endpoint","parsing","format"],"backgroundTag":"invalid-url-format","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}