{"record":{"id":"67304ca701f24d76","repo":"apache/shardingsphere","slug":"invalid-value-for-parameter-client-encoding-s","errorCode":null,"errorMessage":"invalid value for parameter \"client_encoding\": \"%s\"","messagePattern":"invalid value for parameter \"client_encoding\": \"(.+?)\"","errorType":"exception","errorClass":"InvalidParameterValueException","httpStatus":null,"severity":"error","filePath":"proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java","lineNumber":156,"sourceCode":"        PostgreSQLComStartupPacket startupPacket = new PostgreSQLComStartupPacket(payload);\n        clientEncoding = getNormalizedClientEncoding(startupPacket.getClientEncoding());\n        context.channel().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).set(StandardCharsets.UTF_8);\n        String username = startupPacket.getUsername();\n        ShardingSpherePreconditions.checkNotEmpty(username, EmptyUsernameException::new);\n        startupMessageReceived = true;\n        context.writeAndFlush(getIdentifierPacket(username, rule));\n        currentAuthResult = AuthenticationResultBuilder.continued(username, \"\", startupPacket.getDatabase(), startupPacket.getConnectionAttributes());\n        return currentAuthResult;\n    }\n    \n    private String getNormalizedClientEncoding(final String clientEncoding) {\n        String formattedClientEncoding = formatClientEncoding(clientEncoding);\n        String lowerCaseClientEncoding = formattedClientEncoding.toLowerCase(Locale.ROOT);\n        boolean isDefault = \"default\".equals(lowerCaseClientEncoding);\n        boolean isUtf8 = \"utf8\".equals(lowerCaseClientEncoding) || \"utf-8\".equals(lowerCaseClientEncoding) || \"utf_8\".equals(lowerCaseClientEncoding)\n                || \"unicode\".equals(lowerCaseClientEncoding);\n        if (!isDefault && !isUtf8) {\n            throw new InvalidParameterValueException(\"client_encoding\", lowerCaseClientEncoding);\n        }\n        return PostgreSQLCharacterSets.UTF8.name();\n    }\n    \n    private String formatClientEncoding(final String value) {\n        return value.startsWith(\"'\") && value.endsWith(\"'\") || value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\") ? value.substring(1, value.length() - 1).trim() : value.trim();\n    }\n    \n    private PostgreSQLIdentifierPacket getIdentifierPacket(final String username, final AuthorityRule rule) {\n        Optional<Authenticator> authenticator = rule.findUser(new Grantee(username)).map(optional -> new AuthenticatorFactory<>(PostgreSQLAuthenticatorType.class, rule).newInstance(optional));\n        if (authenticator.isPresent() && PostgreSQLAuthenticationMethod.PASSWORD.getMethodName().equals(authenticator.get().getAuthenticationMethodName())) {\n            return new PostgreSQLPasswordAuthenticationPacket();\n        }\n        md5Salt = PostgreSQLRandomGenerator.getInstance().generateRandomBytes(4);\n        return new PostgreSQLMD5PasswordAuthenticationPacket(md5Salt);\n    }\n}\n","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java#L138-L174","documentation":"Error \"invalid value for parameter \"client_encoding\": \"%s\"\" thrown in apache/shardingsphere.","triggerScenarios":"The client supplies an unrecognized client_encoding value in the PostgreSQL startup/authentication phase.","commonSituations":"Misspelled or unsupported charset names (e.g. 'utf-8' vs 'UTF8') in connection parameters.","solutions":["Set client_encoding to a valid PostgreSQL encoding name such as UTF8.","Remove the invalid client_encoding setting from the connection startup packet.","Check for typos in the encoding name."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}