{"record":{"id":"1853ce82aee1fca6","repo":"prestodb/presto","slug":"illegal-character-found-in-username","errorCode":null,"errorMessage":"Illegal character ':' found in username","messagePattern":"Illegal character ':' found in username","errorType":"validation","errorClass":"ClientException","httpStatus":null,"severity":"error","filePath":"presto-client/src/main/java/com/facebook/presto/client/OkHttpUtil.java","lineNumber":90,"sourceCode":"        public void onFailure(Call call, IOException e) {}\n\n        @Override\n        public void onResponse(Call call, Response response) {}\n    }\n\n    public static Interceptor userAgent(String userAgent)\n    {\n        return chain -> chain.proceed(chain.request().newBuilder()\n                .header(USER_AGENT, userAgent)\n                .build());\n    }\n\n    public static Interceptor basicAuth(String user, String password)\n    {\n        requireNonNull(user, \"user is null\");\n        requireNonNull(password, \"password is null\");\n        if (user.contains(\":\")) {\n            throw new ClientException(\"Illegal character ':' found in username\");\n        }\n\n        String credential = Credentials.basic(user, password);\n        return chain -> chain.proceed(chain.request().newBuilder()\n                .header(AUTHORIZATION, credential)\n                .build());\n    }\n\n    public static Interceptor tokenAuth(String accessToken)\n    {\n        requireNonNull(accessToken, \"accessToken is null\");\n        checkArgument(CharMatcher.inRange((char) 33, (char) 126).matchesAllOf(accessToken));\n\n        return chain -> chain.proceed(chain.request().newBuilder()\n                .addHeader(AUTHORIZATION, \"Bearer \" + accessToken)\n                .build());\n    }\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-client/src/main/java/com/facebook/presto/client/OkHttpUtil.java#L72-L108","documentation":"OkHttpUtil.basicAuth builds HTTP Basic auth credentials, which encode user and password as 'user:password'. A colon inside the username would corrupt that encoding, so the library proactively throws ClientException when the user string contains ':'.","triggerScenarios":"Calling OkHttpUtil.basicAuth(user, password) where user contains a colon — typically when a full 'user:password' pair is mistakenly passed as the user argument, or from client session/property wiring that concatenates credentials.","commonSituations":"Config files or connection strings where credentials were specified as 'alice:secret' and the whole string was passed as the username; copy-pasted JDBC URLs; environment variables combining user and password with a separator.","solutions":["Split the value on the first ':' and pass the part before it as user and the part after as password.","Fix the configuration source so username and password are separate fields/variables.","If a colon is genuinely part of the username, use a different auth mechanism (e.g. Kerberos or a token header) instead of basicAuth.","Validate the username in your own config-loading code before constructing the client."],"exampleFix":"// before\nInterceptor auth = OkHttpUtil.basicAuth(\"alice:secret\", null); // ClientException\n// after\nString[] parts = config.split(\":\", 2);\nInterceptor auth = OkHttpUtil.basicAuth(parts[0], parts[1]);","handlingStrategy":"validation","validationCode":"if (user == null || user.contains(\":\")) {\n    throw new IllegalArgumentException(\"username must not contain ':'; split user:password into separate fields\");\n}","typeGuard":null,"tryCatchPattern":"try { Interceptor auth = OkHttpUtil.basicAuth(user, password); } catch (ClientException e) { /* fix credential splitting in config */ }","preventionTips":["Keep username and password in separate config fields","Split any combined 'user:password' string on the first ':' before calling basicAuth","Validate credentials at config-load time, not at request time","Use Kerberos/token auth if usernames legitimately contain colons"],"tags":["authentication","http","presto-client","configuration"],"backgroundTag":"invalid-credential-format","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"}