{"record":{"id":"04711f1f33de0dc2","repo":"apache/shardingsphere","slug":"invalid-value-for-parameter-s-s","errorCode":null,"errorMessage":"invalid value for parameter \"%s\": \"%s\"","messagePattern":"invalid value for parameter \"(.+?)\": \"(.+?)\"","errorType":"exception","errorClass":"InvalidParameterValueException","httpStatus":null,"severity":"error","filePath":"proxy/backend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/variable/charset/PostgreSQLCharsetVariableProvider.java","lineNumber":46,"sourceCode":"import java.util.Locale;\n\n/**\n * Charset variable provider of PostgreSQL.\n */\npublic final class PostgreSQLCharsetVariableProvider implements CharsetVariableProvider {\n    \n    @Override\n    public Collection<String> getCharsetVariables() {\n        return Collections.singleton(\"client_encoding\");\n    }\n    \n    @Override\n    public Charset parseCharset(final String variableValue) {\n        String formattedValue = formatValue(variableValue).toLowerCase(Locale.ROOT);\n        boolean isDefault = \"default\".equals(formattedValue);\n        boolean isUtf8 = \"utf8\".equals(formattedValue) || \"utf-8\".equals(formattedValue) || \"utf_8\".equals(formattedValue) || \"unicode\".equals(formattedValue);\n        if (!isDefault && !isUtf8) {\n            throw new InvalidParameterValueException(\"client_encoding\", formattedValue);\n        }\n        return StandardCharsets.UTF_8;\n    }\n    \n    private String formatValue(final String value) {\n        return QuoteCharacter.SINGLE_QUOTE.isWrapped(value) || QuoteCharacter.QUOTE.isWrapped(value) ? value.substring(1, value.length() - 1).trim() : value.trim();\n    }\n    \n    @Override\n    public String getDatabaseType() {\n        return \"PostgreSQL\";\n    }\n}\n","sourceCodeStart":28,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/backend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/variable/charset/PostgreSQLCharsetVariableProvider.java#L28-L60","documentation":"InvalidParameterValueException ('invalid value for parameter \"client_encoding\": \"%s\"', matching PostgreSQL's own error shape) thrown by PostgreSQLCharsetVariableProvider.parseCharset when the client_encoding value is anything other than 'default', 'utf8', 'utf-8', 'utf_8', or 'unicode' (after lowercasing and quote stripping). The ShardingSphere PostgreSQL proxy only implements UTF-8 client encoding, so every other encoding request is rejected.","triggerScenarios":"A PostgreSQL client issuing SET client_encoding TO 'LATIN1' / 'WIN1252' / 'SQL_ASCII' etc. during connection setup or a session; formatValue strips single/double quotes, and anything not in the UTF-8 alias set throws InvalidParameterValueException('client_encoding', value).","commonSituations":"Legacy clients or drivers configured for LATIN1/EUC-JP connecting through the proxy; psql clients inheriting a non-UTF8 locale issuing SET client_encoding; GUI tools that probe/force encodings on connect.","solutions":["Configure the client to use UTF-8: set PGCLIENTENCODING=UTF8, pass ?options=-c client_encoding=utf8, or set the driver's charSet/encoding property to UTF-8","Change the client terminal/locale to UTF-8 so psql does not request a legacy encoding","If a non-UTF8 encoding is a hard requirement, it is unsupported by the proxy — terminate the encoding conversion in the application instead"],"exampleFix":"# before\nPGCLIENTENCODING=LATIN1 psql -h proxy -p 3307 -d demo\n\n# after\nPGCLIENTENCODING=UTF8 psql -h proxy -p 3307 -d demo","handlingStrategy":"validation","validationCode":"private static final Set<String> SUPPORTED = Set.of(\"default\", \"utf8\", \"utf-8\", \"utf_8\", \"unicode\");\npublic void checkClientEncoding(final String value) {\n    String v = value.trim().toLowerCase(Locale.ROOT);\n    if (!SUPPORTED.contains(v)) { throw new IllegalArgumentException(\"Only UTF-8 client_encoding is supported: \" + v); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set PGCLIENTENCODING=UTF8 (or driver encoding=UTF-8) for every client connecting through the proxy","Run terminals/CI environments in UTF-8 locales so clients do not negotiate legacy encodings"],"tags":["postgresql","charset","client-encoding","dialect","validation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}