{"record":{"id":"dddc09977fa4c793","repo":"prestodb/presto","slug":"invalid-server-url","errorCode":null,"errorMessage":"Invalid server URL: ","messagePattern":"Invalid server URL: ","errorType":"validation","errorClass":"ClientException","httpStatus":null,"severity":"error","filePath":"presto-client/src/main/java/com/facebook/presto/client/StatementClientV1.java","lineNumber":151,"sourceCode":"        this.validateNextUriSource = session.validateNextUriSource();\n\n        Request request = buildQueryRequest(session, query);\n\n        JsonResponse<QueryResults> response = JsonResponse.execute(QUERY_RESULTS_CODEC, httpClient, request);\n        if ((response.getStatusCode() != HTTP_OK) || !response.hasValue()) {\n            state.compareAndSet(State.RUNNING, State.CLIENT_ERROR);\n            throw requestFailedException(\"starting query\", request, response);\n        }\n\n        processResponse(response.getHeaders(), response.getValue());\n        this.responseHeaders = toHeaderMap(response.getHeaders());\n    }\n\n    private Request buildQueryRequest(ClientSession session, String query)\n    {\n        HttpUrl url = HttpUrl.get(session.getServer());\n        if (url == null) {\n            throw new ClientException(\"Invalid server URL: \" + session.getServer());\n        }\n        url = url.newBuilder().encodedPath(\"/v1/statement\").build();\n\n        Request.Builder builder = prepareRequest(url)\n                .post(RequestBody.create(MEDIA_TYPE_TEXT, query));\n\n        Map<String, String> customHeaders = session.getCustomHeaders();\n        for (Entry<String, String> entry : customHeaders.entrySet()) {\n            builder.addHeader(entry.getKey(), entry.getValue());\n        }\n\n        if (session.getSource() != null) {\n            builder.addHeader(PRESTO_SOURCE, session.getSource());\n        }\n\n        session.getTraceToken().ifPresent(token -> builder.addHeader(PRESTO_TRACE_TOKEN, token));\n\n        if (session.getClientTags() != null && !session.getClientTags().isEmpty()) {","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-client/src/main/java/com/facebook/presto/client/StatementClientV1.java#L133-L169","documentation":"buildQueryRequest parses session.getServer() with OkHttp's HttpUrl.get, which returns null for URLs that are not valid absolute HTTP(S) URLs; the code then throws ClientException 'Invalid server URL: <url>'. The library cannot even construct the /v1/statement request because the server address is malformed.","triggerScenarios":"Creating a StatementClientV1 (presto CLI/JDBC startQuery) with a session server string like 'presto.example.com:8080' (no scheme), 'http:/host' (malformed), or containing illegal characters.","commonSituations":"Forgetting the http:// or https:// scheme; trailing typos or spaces in the --server argument; environment variable/POM substitution leaving a placeholder like ${PRESTO_SERVER}; using ftp:// or a bare hostname.","solutions":["Include an explicit scheme: http://host:port or https://host:port.","Print/inspect the server string actually passed (check env vars and config substitution).","Validate the URL with HttpUrl.get(...) or `new URL(...)` before constructing the client.","Remove whitespace or invalid characters from the server setting."],"exampleFix":"// before\npresto --server presto.example.com:8080\n// after\npresto --server http://presto.example.com:8080","handlingStrategy":"validation","validationCode":"String server = session.getServer();\nif (server == null || !server.matches(\"^https?://[^\\s]+$\")) {\n    throw new IllegalArgumentException(\"Server must be an absolute http(s) URL: \" + server);\n}","typeGuard":null,"tryCatchPattern":"try { client.startQuery(session, sql); } catch (ClientException e) { if (e.getMessage().startsWith(\"Invalid server URL\")) { /* fix server config and retry */ } throw e; }","preventionTips":["Always include http:// or https:// scheme in --server","Validate config substitution (no leftover ${PLACEHOLDER})","Trim whitespace from URL settings","Smoke-test the URL with curl before running queries"],"tags":["url","configuration","presto-client"],"backgroundTag":"invalid-url","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}