{"record":{"id":"a7bac0f861e7f1ac","repo":"flowable/flowable-engine","slug":"the-dmn-xml-is-not-properly-encoded","errorCode":null,"errorMessage":"The dmn xml is not properly encoded","messagePattern":"The dmn xml is not properly encoded","errorType":"validation","errorClass":"DmnXMLException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/DmnXMLConverter.java","lineNumber":249,"sourceCode":"        }\n        \n        if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_DTD)) {\n            xif.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, \"\");\n        }\n        \n        if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_SCHEMA)) {\n            xif.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, \"\");\n        }\n\n        if (validateSchema) {\n            try (InputStreamReader in = new InputStreamReader(inputStreamProvider.getInputStream(), encoding)) {\n                if (!enableSafeDmnXml) {\n                    validateModel(inputStreamProvider);\n                } else {\n                    validateModel(xif.createXMLStreamReader(in));\n                }\n            } catch (UnsupportedEncodingException e) {\n                throw new DmnXMLException(\"The dmn xml is not properly encoded\", e);\n            } catch (XMLStreamException e) {\n                throw new DmnXMLException(\"Error while reading the dmn xml file\", e);\n            } catch (Exception e) {\n                throw new DmnXMLException(e.getMessage(), e);\n            }\n        }\n        // The input stream is closed after schema validation\n        try (InputStreamReader in = new InputStreamReader(inputStreamProvider.getInputStream(), encoding)) {\n            // XML conversion\n            return convertToDmnModel(xif.createXMLStreamReader(in));\n        } catch (UnsupportedEncodingException e) {\n            throw new DmnXMLException(\"The dmn xml is not properly encoded\", e);\n        } catch (XMLStreamException e) {\n            throw new DmnXMLException(\"Error while reading the dmn xml file\", e);\n        } catch (IOException e) {\n            throw new DmnXMLException(e.getMessage(), e);\n        }\n    }","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/DmnXMLConverter.java#L231-L267","documentation":"In convertToDmnModel(InputStreamProvider, validateSchema, enableSafeDmnXml, encoding), the first validation pass opens the input stream with the given encoding. If java throws UnsupportedEncodingException (the encoding name is not a supported charset), it becomes DmnXMLException \"The dmn xml is not properly encoded\".","triggerScenarios":"Passing an invalid charset name to the 4-arg convertToDmnModel — e.g. convertToDmnModel(provider, true, true, \"utf8-longname\") — or a JDK lacking that charset; both the validation and conversion readers use this encoding.","commonSituations":"Typo in encoding string read from configuration (\"UTF-8\" vs \"utf_8\"); locale-dependent config producing wrong charset names; running on a JVM with a minimal charsets package (older/embedded JREs).","solutions":["Use a canonical charset name like \"UTF-8\" or a StandardCharsets.name() constant","Validate the configured encoding via Charset.isSupported(name) before calling","Check the JVM supports the requested charset (Charset.availableCharsets())","Fall back to the 3-arg convertToDmnModel which uses DEFAULT_ENCODING"],"exampleFix":"// before\nconverter.convertToDmnModel(provider, true, true, \"utf8\");\n// after\nconverter.convertToDmnModel(provider, true, true, StandardCharsets.UTF_8.name());","handlingStrategy":"validation","validationCode":"if (!Charset.isSupported(encoding)) { throw new IllegalArgumentException(\"Unsupported charset: \" + encoding); }","typeGuard":null,"tryCatchPattern":"try { converter.convertToDmnModel(provider, true, true, encoding); } catch (DmnXMLException e) { if (e.getCause() instanceof UnsupportedEncodingException) { log.error(\"Bad charset: {}\", encoding); } }","preventionTips":["Only pass charset names from StandardCharsets constants","Validate configured encodings at startup, not at conversion time","Prefer the 3-arg overload when a custom encoding is not needed"],"tags":["encoding","charset","xml","configuration"],"backgroundTag":"invalid-argument-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}