{"record":{"id":"823884a548ce7db1","repo":"quarkusio/quarkus","slug":"failed-to-encode-options-params","errorCode":null,"errorMessage":"failed to encode options params","messagePattern":"failed to encode options params","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/jdbc/jdbc-postgresql/runtime/src/main/java/io/quarkus/jdbc/postgresql/runtime/PostgreSQLServiceBindingConverter.java","lineNumber":90,"sourceCode":"                    }\n                }\n            }\n\n            String combinedOptions = crdbOption;\n            if (postgreOptions.size() > 0) {\n                String otherOpts = String.join(\" \", postgreOptions);\n                if (!combinedOptions.equals(\"\")) {\n                    combinedOptions = combinedOptions + \" \" + otherOpts;\n                } else {\n                    combinedOptions = otherOpts;\n                }\n            }\n\n            try {\n                combinedOptions = combinedOptions.length() > 0 ? OPTIONS + \"=\" + encode(combinedOptions).replace(\"+\", \"%20\")\n                        : \"\";\n            } catch (UnsupportedEncodingException e) {\n                throw new IllegalArgumentException(\"failed to encode options params\" + options, e);\n            }\n\n            if (sslparam.length() > 0 && !combinedOptions.equals(\"\")) {\n                combinedOptions = sslparam + \"&\" + combinedOptions;\n            } else if (sslparam.length() > 0) {\n                combinedOptions = sslparam.toString();\n            }\n\n            if (!\"\".equals(combinedOptions)) {\n                //append sslmode and options to the URL\n                result += \"?\" + combinedOptions;\n            }\n\n            return result;\n        }\n\n        private String encode(String str) throws UnsupportedEncodingException {\n            return URLEncoder.encode(str, StandardCharsets.UTF_8.toString());","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/jdbc/jdbc-postgresql/runtime/src/main/java/io/quarkus/jdbc/postgresql/runtime/PostgreSQLServiceBindingConverter.java#L72-L108","documentation":"PostgreSQLServiceBindingConverter.formatUrl() URL-encodes the combined connection 'options' parameter (e.g. search_path and SSL parameters) taken from a service binding secret. If the platform charset is unsupported, URLEncoder.encode throws UnsupportedEncodingException, which is wrapped into this IllegalArgumentException. It signals the service-binding-generated options string could not be turned into a safe JDBC URL.","triggerScenarios":"Binding a PostgreSQL datasource via a Kubernetes service binding whose secret contains an 'options' field, while URLEncoder.encode(String, \"UTF-8\") throws UnsupportedEncodingException (charset unavailable in the runtime environment).","commonSituations":"Running on a JRE image missing the charset; exotic native-image builds stripping charsets; malformed binding secrets producing unexpected options values.","solutions":["Ensure the runtime image/JVM supports the UTF-8 charset (use a full JDK or a base image with charsets included).","Check the service binding secret's 'options' value for invalid or non-standard content and fix the binding.","Upgrade the Quarkus postgresql extension: newer code uses StandardCharsets/encode(float) style APIs that cannot throw this.","As a workaround, build the JDBC URL manually from the binding values instead of relying on the converter."],"exampleFix":"// before: rely on service binding converter with restricted runtime\nquarkus.datasource.jdbc.url=<from binding secret options>\n// after: set URL explicitly and pre-encode options\nquarkus.datasource.jdbc.url=jdbc:postgresql://host/db?options=-c%20search_path%3Dmyschema","handlingStrategy":"try-catch","validationCode":"boolean charsetOk;\ntry {\n    \"x\".getBytes(\"UTF-8\");\n    charsetOk = true;\n} catch (UnsupportedEncodingException e) {\n    charsetOk = false;\n}","typeGuard":null,"tryCatchPattern":"try {\n    URL url = converter.formatUrl(binding);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"failed to encode options params\")) {\n        log.error(\"Service binding options not encodable; check secret content and runtime charset\", e);\n    } else { throw e; }\n}","preventionTips":["Use runtime images that include the full charset set","Keep binding secret 'options' values simple and ASCII-safe","Pin the JDBC URL explicitly in production instead of deriving it from bindings"],"tags":["postgresql","url-encoding","service-binding","kubernetes"],"backgroundTag":"url-encoding-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}