{"record":{"id":"3e55d374f3bcc1dd","repo":"pentaho/pentaho-kettle","slug":"switchcasemeta-exception-unabletoloadstepinfofromxml","errorCode":"SwitchCaseMeta.Exception..UnableToLoadStepInfoFromXML","errorMessage":"SwitchCaseMeta.Exception..UnableToLoadStepInfoFromXML","messagePattern":"SwitchCaseMeta\\.Exception\\.\\.UnableToLoadStepInfoFromXML","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/switchcase/SwitchCaseMeta.java","lineNumber":178,"sourceCode":"      caseValueType = ValueMetaBase.getType( XMLHandler.getTagValue( stepnode, \"case_value_type\" ) );\n      caseValueFormat = XMLHandler.getTagValue( stepnode, \"case_value_format\" );\n      caseValueDecimal = XMLHandler.getTagValue( stepnode, \"case_value_decimal\" );\n      caseValueGroup = XMLHandler.getTagValue( stepnode, \"case_value_group\" );\n\n      defaultTargetStepname = XMLHandler.getTagValue( stepnode, \"default_target_step\" );\n\n      Node casesNode = XMLHandler.getSubNode( stepnode, XML_TAG_CASE_VALUES );\n      int nrCases = XMLHandler.countNodes( casesNode, XML_TAG_CASE_VALUE );\n      allocate();\n      for ( int i = 0; i < nrCases; i++ ) {\n        Node caseNode = XMLHandler.getSubNodeByNr( casesNode, XML_TAG_CASE_VALUE, i );\n        SwitchCaseTarget target = new SwitchCaseTarget();\n        target.caseValue = XMLHandler.getTagValue( caseNode, \"value\" );\n        target.caseTargetStepname = XMLHandler.getTagValue( caseNode, \"target_step\" );\n        caseTargets.add( target );\n      }\n    } catch ( Exception e ) {\n      throw new KettleXMLException( BaseMessages.getString(\n        PKG, \"SwitchCaseMeta.Exception..UnableToLoadStepInfoFromXML\" ), e );\n    }\n  }\n\n  public void setDefault() {\n    allocate();\n  }\n\n  public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException {\n    try {\n      fieldname = rep.getStepAttributeString( id_step, \"fieldname\" );\n      isContains = rep.getStepAttributeBoolean( id_step, \"use_contains\" );\n      caseValueType = ValueMetaBase.getType( rep.getStepAttributeString( id_step, \"case_value_type\" ) );\n      caseValueFormat = rep.getStepAttributeString( id_step, \"case_value_format\" );\n      caseValueDecimal = rep.getStepAttributeString( id_step, \"case_value_decimal\" );\n      caseValueGroup = rep.getStepAttributeString( id_step, \"case_value_group\" );\n\n      defaultTargetStepname = rep.getStepAttributeString( id_step, \"default_target_step\" );","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/switchcase/SwitchCaseMeta.java#L160-L196","documentation":"KettleXMLException thrown by SwitchCaseMeta.readData (invoked from loadXML) when an unexpected exception occurs while parsing the Switch/Case step's XML definition — specifically while reading case nodes into SwitchCaseTarget entries (value, target_step tags). Any XMLHandler failure or unexpected structure inside the try block is wrapped with this localized message and rethrown.","triggerScenarios":"Loading a .ktr from file/XML when the <cases> nodes are malformed, the XML schema changed between Pentaho versions, or the file was hand-edited/corrupted so XMLHandler.getTagValue throws or encounters unexpected structure.","commonSituations":"Hand-editing ktr files and breaking the case node structure; opening transformations created in newer/older PDI versions with different XML layout; truncated or corrupted files from bad version-control merges or incomplete transfers.","solutions":["Check the chained cause for the exact XML parsing problem and fix that node in the .ktr file.","Open the transformation in Spoon of the matching PDI version; if needed, export a fresh XML instead of hand-editing.","Validate the .ktr XML well-formedness (XML parser/xmllint) and repair or regenerate the case nodes.","Restore the file from version control or re-create the Switch/Case step if the XML is unrecoverable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate XML well-formedness before loading\ntry { DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( new File( ktrPath ) ); }\ncatch ( Exception e ) { throw new IllegalStateException( \"ktr XML malformed: \" + ktrPath, e ); }","typeGuard":null,"tryCatchPattern":"try { transMeta.loadXML( file, ... ); } catch ( KettleXMLException e ) { log.error( \"Switch/Case XML load failed: \" + e.getCause(), e ); throw e; }","preventionTips":["Never hand-edit .ktr XML; use Spoon.","Commit transformations only after Spoon validates them.","Use the same PDI version for editing and running.","Version-control files with proper merge checks."],"tags":["kettle","xml","metadata-load","pdi"],"backgroundTag":"json-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"}