pentaho/pentaho-kettle · warning · KettleException

There is no target to do a field mapping against!

Error message

There is no target to do a field mapping against!

What it means

Spoon's field-mapping generation throws KettleException 'There is no target to do a field mapping against!' when the user initiates a field mapping between two steps in a transformation but the target step reference is null. The exception is immediately caught and shown via ErrorDialog, so users see 'Error creating mapping' rather than a crash.

Solutions

  1. Select both source and target steps in the transformation canvas before invoking field mapping
  2. Verify the target step still exists in the transformation (not deleted/renamed) before mapping
  3. Ensure the active transformation has at least two steps; the action is meaningless otherwise
  4. If embedding Spoon programmatically, pass a valid non-null target step to the mapping helper

Example fix

// before
spoon.generateFieldMapping(sourceStep, targetStep); // targetStep may be null
// after
if ( targetStep != null ) {
  spoon.generateFieldMapping(sourceStep, targetStep);
} else {
  JOptionPane.showMessageDialog(null, "Select a target step first");
}
Defensive patterns

Strategy: validation

Validate before calling

if (transMeta == null || transMeta.getSelectedSteps() == null || transMeta.getSelectedSteps().length < 2) {
  JOptionPane.showMessageDialog(shell, "Select a source and target step before field mapping");
  return;
}

Type guard

boolean hasMappingTarget(TransMeta tm) {
  return tm != null && tm.getSelectedSteps() != null && tm.getSelectedSteps().length >= 2;
}

Try / catch

try {
  generateFieldMapping(sourceStep, targetStep);
} catch (KettleException e) {
  new ErrorDialog(shell, "Field mapping", "Select a target step first", e);
}

Prevention

When it happens

Trigger: Invoking the field-mapping action (mapping between a source and target step) when transMeta's selected/second step cannot be resolved — e.g. only one step selected, no step selected as target, or the target step reference variable is null in the Spoon graph.

Common situations: Clicking the field-mapping toolbar/menu item with only one step selected; selection changed between opening the dialog and confirming; the mapping target step was deleted from the canvas while the mapping dialog was open.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/b70c96ec79135a78. Report an issue: GitHub.

Appendix: source

Thrown at ui/src/main/java/org/pentaho/di/ui/spoon/Spoon.java:9315

          // a new comment. Sincerely yours CO ;)
          // Now that we have the meta-data, create a new step info object
          String stepName = stepMeta.getName() + " Mapping";
          stepName = transMeta.getAlternativeStepname( stepName ); // if
          // it's already there, rename it.

          StepMeta newStep = new StepMeta( "SelectValues", stepName, svm );
          newStep.setLocation( stepMeta.getLocation().x + 20, stepMeta.getLocation().y + 20 );
          newStep.setDraw( true );

          transMeta.addStep( newStep );
          addUndoNew( transMeta, new StepMeta[] { newStep }, new int[] { transMeta.indexOfStep( newStep ) } );

          // Redraw stuff...
          refreshTree();
          refreshGraph();
        }
      } else {
        throw new KettleException( "There is no target to do a field mapping against!" );
      }
    } catch ( KettleException e ) {
      new ErrorDialog(
        shell, "Error creating mapping",
        "There was an error when Kettle tried to generate a field mapping against the target step", e );
    }
  }

  public boolean isDefinedSchemaExist( String[] schemaNames ) {
    // Before we start, check if there are any partition schemas defined...
    if ( ( schemaNames == null ) || ( schemaNames.length == 0 ) ) {
      MessageBox box = new MessageBox( shell, SWT.ICON_ERROR | SWT.OK );
      box.setText( "Create a partition schema" );
      box.setMessage( "You first need to create one or more partition schemas in "
        + "the transformation settings dialog before you can select one!" );
      box.open();
      return false;
    }

View on GitHub (pinned to f3058517a1)