{"record":{"id":"dce6f68da67aa57e","repo":"pentaho/pentaho-kettle","slug":"it-was-not-possibke-to-load-the-trim-metadata-from-xml","errorCode":null,"errorMessage":"It was not possibke to load the Trim metadata from XML","messagePattern":"It was not possibke to load the Trim metadata from XML","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/tablecompare/TableCompareMeta.java","lineNumber":456,"sourceCode":"      compareSchemaField = XMLHandler.getTagValue( stepnode, \"compare_schema_field\" );\n      compareTableField = XMLHandler.getTagValue( stepnode, \"compare_table_field\" );\n\n      keyFieldsField = XMLHandler.getTagValue( stepnode, \"key_fields_field\" );\n      excludeFieldsField = XMLHandler.getTagValue( stepnode, \"exclude_fields_field\" );\n      nrErrorsField = XMLHandler.getTagValue( stepnode, \"nr_errors_field\" );\n\n      nrRecordsReferenceField = XMLHandler.getTagValue( stepnode, \"nr_records_reference_field\" );\n      nrRecordsCompareField = XMLHandler.getTagValue( stepnode, \"nr_records_compare_field\" );\n      nrErrorsLeftJoinField = XMLHandler.getTagValue( stepnode, \"nr_errors_left_join_field\" );\n      nrErrorsInnerJoinField = XMLHandler.getTagValue( stepnode, \"nr_errors_inner_join_field\" );\n      nrErrorsRightJoinField = XMLHandler.getTagValue( stepnode, \"nr_errors_right_join_field\" );\n\n      keyDescriptionField = XMLHandler.getTagValue( stepnode, \"key_description_field\" );\n      valueReferenceField = XMLHandler.getTagValue( stepnode, \"value_reference_field\" );\n      valueCompareField = XMLHandler.getTagValue( stepnode, \"value_compare_field\" );\n\n    } catch ( Exception e ) {\n      throw new KettleXMLException( \"It was not possibke to load the Trim metadata from XML\", e );\n    }\n  }\n\n  @Override\n  public String getXML() {\n    StringBuilder retval = new StringBuilder();\n\n    retval.append( \"      \" ).append(\n      XMLHandler.addTagValue( \"reference_connection\", referenceConnection == null ? null : referenceConnection\n        .getName() ) );\n    retval.append( \"      \" ).append( XMLHandler.addTagValue( \"reference_schema_field\", referenceSchemaField ) );\n    retval.append( \"      \" ).append( XMLHandler.addTagValue( \"reference_table_field\", referenceTableField ) );\n\n    retval.append( \"      \" ).append(\n      XMLHandler.addTagValue( \"compare_connection\", compareConnection == null ? null : compareConnection\n        .getName() ) );\n    retval.append( \"      \" ).append( XMLHandler.addTagValue( \"compare_schema_field\", compareSchemaField ) );\n    retval.append( \"      \" ).append( XMLHandler.addTagValue( \"compare_table_field\", compareTableField ) );","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/tablecompare/TableCompareMeta.java#L438-L474","documentation":"TableCompareMeta.readData() wraps any Exception raised while parsing the step's XML node into a KettleXMLException with the (typo'd) message 'It was not possibke to load the Trim metadata from XML'. It indicates the <step> node for a TableCompare step is malformed or missing expected tags.","triggerScenarios":"readData(stepnode) called from loadXML when XMLHandler.getTagValue throws or the XML structure is invalid — e.g. corrupt .ktr file, wrong nesting of step node tags, incompatible XML produced by another version.","commonSituations":"Hand-edited or truncated .ktr files; merging transformations with conflicting XML; loading a .ktr saved by a different Pentaho version with schema drift; copy-paste errors in the step XML block.","solutions":["Inspect the cause (getCause()) to find the exact XML parsing failure and fix the offending tag in the .ktr.","Re-open the transformation in Spoon and re-create/re-configure the TableCompare step to regenerate valid XML.","Restore the .ktr from version control/backup if it was truncated or corrupted.","Check the step attributes (key_description_field, value_reference_field, value_compare_field etc.) are correctly nested under the step node."],"exampleFix":"// before (broken .ktr fragment)\n<step><name>Table compare</name>\n  <key_description_field>desc\n// after (well-formed)\n<step><name>Table compare</name>\n  <key_description_field>desc</key_description_field>\n  <value_reference_field>ref_val</value_reference_field>\n  <value_compare_field>cmp_val</value_compare_field>\n</step>","handlingStrategy":"try-catch","validationCode":"// validate the XML is well-formed and contains expected tags before loadXML\nDocument doc = XMLHandler.loadXMLFile( ktrFile );\nif ( XMLHandler.getTagValue( doc, \"step\", \"key_description_field\" ) == null ) {\n  throw new IllegalStateException( \"TableCompare step XML missing key_description_field\" );\n}","typeGuard":null,"tryCatchPattern":"try {\n  transMeta.loadXML( file, ... );\n} catch ( KettleXMLException e ) {\n  if ( e.getMessage().contains( \"Trim metadata\" ) ) {\n    logError( \"Corrupt TableCompare step XML: \" + e.getCause() );\n    // restore from backup or re-create the step\n  }\n}","preventionTips":["Never hand-edit .ktr files without validating XML afterwards (xmllint or opening in Spoon).","Keep .ktr files under version control so corrupt edits can be reverted.","When copying steps between transformations, copy the entire <step> node including all child tags."],"tags":["kettle","xml","parsing","corrupt-file"],"backgroundTag":"xml-parse-error","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"}