{"record":{"id":"1e31b20d4c59f393","repo":"quarkusio/quarkus","slug":"unable-to-create-charset-from-trimmedcharset","errorCode":null,"errorMessage":"Unable to create Charset from: '${trimmedCharset}'","messagePattern":"Unable to create Charset from: '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/runtime/src/main/java/io/quarkus/runtime/configuration/CharsetConverter.java","lineNumber":35,"sourceCode":"\n    private static final long serialVersionUID = 2320905063828247874L;\n\n    @Override\n    public Charset convert(String value) {\n        if (value == null) {\n            return null;\n        }\n\n        String trimmedCharset = value.trim();\n\n        if (trimmedCharset.isEmpty()) {\n            return null;\n        }\n\n        try {\n            return Charset.forName(trimmedCharset);\n        } catch (Exception e) {\n            throw new IllegalArgumentException(\"Unable to create Charset from: '\" + trimmedCharset + \"'\", e);\n        }\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":39,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/runtime/src/main/java/io/quarkus/runtime/configuration/CharsetConverter.java#L17-L39","documentation":"CharsetConverter.convert() turns a config string into a java.nio.charset.Charset. When Charset.forName(trimmedCharset) fails (unknown or unsupported charset name), it wraps the exception in IllegalArgumentException(\"Unable to create Charset from: '<value>'\").","triggerScenarios":"Setting a quarkus property that maps to Charset (e.g. quarkus.http.* charset settings, file encoding configs) to an invalid name like 'utf8' vs 'UTF-8', a typo, or an empty/whitespace-only non-null value that passes trimming.","commonSituations":"Typo in application.properties (e.g. 'utf-8' works, 'utf8' may fail depending on JDK); charset supported on one JDK but not another; OS-specific default encoding names copied into config.","solutions":["Use a canonical charset name: 'UTF-8', 'ISO-8859-1', 'US-ASCII', etc.","Run Charset.isSupported(name) or Charset.forName in a scratch program to validate the name on your JDK.","Check for typos and stray characters (BOM, quotes) in the property value.","If nullable, leave the property unset rather than supplying a bad value."],"exampleFix":"// before\nquarkus.http.body.charset=utf8\n// after\nquarkus.http.body.charset=UTF-8","handlingStrategy":"validation","validationCode":"boolean isValidCharset(String s) {\n    if (s == null) return false;\n    String t = s.trim();\n    return !t.isEmpty() && java.nio.charset.Charset.isSupported(t);\n}","typeGuard":"java.nio.charset.Charset tryParseCharset(String s) {\n    try { return (s == null || s.isBlank()) ? null : java.nio.charset.Charset.forName(s.trim()); }\n    catch (Exception e) { return null; }\n}","tryCatchPattern":"try {\n    // consume the converted charset\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unable to create Charset from:\")) {\n        charset = StandardCharsets.UTF_8; // sane default\n    } else { throw e; }\n}","preventionTips":["Use canonical JVM charset names (UTF-8, ISO-8859-1)","Validate charset strings with Charset.isSupported before shipping config","Beware JDK/OS-specific charset aliases"],"tags":["configuration","charset","converter"],"backgroundTag":"invalid-config-value","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"}