{"record":{"id":"0623d67b2400f8ea","repo":"pentaho/pentaho-kettle","slug":"addxml-exception-fieldnotfound-localized-message-with-field","errorCode":null,"errorMessage":"AddXML.Exception.FieldNotFound (localized message with field name)","messagePattern":"AddXML\\.Exception\\.FieldNotFound \\(localized message with field name\\)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/addxml/AddXML.java","lineNumber":94,"sourceCode":"      setOutputDone();\n      return false;\n    }\n\n    if ( first ) {\n      first = false;\n\n      data.outputRowMeta = getInputRowMeta().clone();\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n                      metaStore );\n\n      // Cache the field name indexes\n      //\n      data.fieldIndexes = new int[meta.getOutputFields().length];\n      for ( int i = 0; i < data.fieldIndexes.length; i++ ) {\n        String fieldsName = meta.getOutputFields()[i].getFieldName();\n        data.fieldIndexes[i] = getInputRowMeta().indexOfValue( fieldsName );\n        if ( data.fieldIndexes[i] < 0 ) {\n          throw new KettleException( BaseMessages.getString( PKG, \"AddXML.Exception.FieldNotFound\", fieldsName ) );\n        }\n      }\n    }\n\n    Document xmldoc = getDomImplentation().createDocument( null, meta.getRootNode(), null );\n    Element root = xmldoc.getDocumentElement();\n    for ( int i = 0; i < meta.getOutputFields().length; i++ ) {\n      XMLField outputField = meta.getOutputFields()[i];\n      String fieldname = outputField.getFieldName();\n\n      ValueMetaInterface v = getInputRowMeta().getValueMeta( data.fieldIndexes[i] );\n      Object valueData = r[data.fieldIndexes[i]];\n\n      if ( !meta.isOmitNullValues() || !v.isNull( valueData ) ) {\n        String value = formatField( v, valueData, outputField );\n\n        String element = outputField.getElementName();\n        if ( element == null || element.length() == 0 ) {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/addxml/AddXML.java#L76-L112","documentation":"The AddXML step looks up each configured output field's index in the incoming row metadata; if a field name is not present in the input stream (indexOfValue < 0) it throws KettleException with the localized message AddXML.Exception.FieldNotFound parameterized with the field name. The step cannot build XML from fields that never arrive.","triggerScenarios":"processRow() first-row initialization: meta.getOutputFields()[i].getFieldName() is not found in getInputRowMeta().","commonSituations":"Upstream step renamed or removed the field; field arrives only on some rows' metadata; copy/paste of step config between transformations with different layouts; variable-driven field name that doesn't resolve.","solutions":["Update the AddXML field list to match the actual incoming field names","Restore the field in the upstream step","Re-run 'Get Fields' in the step dialog to refresh the mapping","Remove stale entries for fields no longer produced"],"exampleFix":"// before: field renamed upstream but AddXML still references old name\nnew XMLField( \"amount_old\", ... );\n// after: reference the renamed field\nnew XMLField( \"amount\", ... );","handlingStrategy":"validation","validationCode":"for ( XMLField f : meta.getOutputFields() ) {\n  if ( inputRowMeta.indexOfValue( f.getFieldName() ) < 0 ) {\n    throw new IllegalStateException( \"Field not in input stream: \" + f.getFieldName() );\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  step.processRow( meta, data );\n} catch ( KettleException e ) {\n  logError( \"AddXML configuration error: \" + e.getMessage(), e );\n  stopAll();\n  setErrors( 1 );\n}","preventionTips":["Refresh the field list ('Get Fields') after any upstream change","Avoid renaming fields without downstream impact analysis","Check variable-driven field names resolve at runtime","Use a specification/impact report before refactoring stream layouts"],"tags":["addxml","field-not-found","stream-layout","transformation"],"backgroundTag":"field-not-found","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"}