{"record":{"id":"0fea89cf55dd6a48","repo":"pentaho/pentaho-kettle","slug":"there-was-a-value-xml-encoding-error","errorCode":null,"errorMessage":" : there was a value XML encoding error","messagePattern":" : there was a value XML encoding error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":3401,"sourceCode":"            //\n            string = XMLHandler.addTagValue( \"binary-string\", (byte[]) object );\n            xml.append( XMLHandler.openTag( XML_DATA_TAG ) ).append( string ).append( XMLHandler.closeTag( XML_DATA_TAG ) );\n            return xml.toString();\n\n          case STORAGE_TYPE_INDEXED:\n            // Just an index\n            string = XMLHandler.addTagValue( \"index-value\", (Integer) object );\n            break;\n\n          default:\n            throw new IOException( toString() + \" : Unknown storage type \" + getStorageType() );\n        }\n      } catch ( ClassCastException e ) {\n        throw new RuntimeException( toString() + \" : There was a data type error: the data type of \"\n            + object.getClass().getName() + \" object [\" + object + \"] does not correspond to value meta [\"\n            + toStringMeta() + \"]\", e );\n      } catch ( Exception e ) {\n        throw new RuntimeException( toString() + \" : there was a value XML encoding error\", e );\n      }\n    } else {\n      // If the object is null: give an empty string\n      //\n      string = \"\";\n    }\n    xml.append( XMLHandler.addTagValue( XML_DATA_TAG, string ) );\n\n    return xml.toString();\n  }\n\n  /**\n   * Convert a data XML node to an Object that corresponds to the metadata. This is basically String to Object\n   * conversion that is being done.\n   *\n   * @param node\n   *          the node to retrieve the data value from\n   * @return the converted data value","sourceCodeStart":3383,"sourceCodeEnd":3419,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L3383-L3419","documentation":"In ValueMetaBase.getXML, after the type-specific and storage-type-specific handling, any remaining Exception during value-to-XML encoding (e.g. date/number formatting failures) is caught and rethrown as a RuntimeException with this message. It means the value could not be encoded to its XML string form for reasons other than a hard type mismatch.","triggerScenarios":"Calling getXML(object) where encoding fails inside the type branch — e.g. XMLHandler.string2string/escaping problems, a formatting exception from a broken conversion mask, or an unexpected exception thrown while converting the object's string representation.","commonSituations":"Malformed conversion format strings set on the value meta; custom data objects whose toString() throws; encoding/charset issues producing invalid intermediate strings; plugin values not conforming to the expected contract.","solutions":["Read the cause (RuntimeException.getCause()) to find the actual encoding failure and fix it (format mask, charset, toString implementation).","Validate the value meta's conversion format masks (setConversionMask) — invalid patterns break encoding.","Convert custom objects to supported Java types before putting them into the row.","Test getXML on a sample row in isolation to reproduce and pinpoint the failing value."],"exampleFix":"// before: bad mask causes encoding exception\nvm.setConversionMask(\"dd/MM/yyyy HH:mm:ss SSS 'x'\"); // malformed pattern\n// after\nvm.setConversionMask(\"dd/MM/yyyy HH:mm:ss\");","handlingStrategy":"try-catch","validationCode":"try {\n  new SimpleDateFormat(vm.getConversionMask());\n} catch (IllegalArgumentException iae) {\n  throw new IllegalStateException(\"Invalid conversion mask: \" + vm.getConversionMask());\n}","typeGuard":null,"tryCatchPattern":"try {\n  String xml = valueMeta.getXML(data);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"value XML encoding error\")) {\n    logError(\"XML encoding failed for \" + valueMeta.getName() + \": \" + e.getCause(), e.getCause());\n  }\n  throw e;\n}","preventionTips":["Validate conversion masks against the declared data type when configuring fields.","Ensure custom row objects implement a safe toString() and are convertible to supported types.","Isolate and log the failing field so one bad value does not abort an entire export."],"tags":["xml","encoding","serialization","runtime-exception"],"backgroundTag":"json-marshal-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}