pentaho/pentaho-kettle · error · KettleException
Unexpected error occurred while injecting metadata
Error message
Unexpected error occurred while injecting metadata
What it means
Generic wrapper thrown by MetaInject.oldInjection() when any unexpected exception occurs while applying the injection mapping entries to the target steps of the child transformation. Per-entry metadata (source field/target field/target step) is set reflectively; a failure inside that loop — bad target step, incompatible field type, reflection error — is wrapped in this KettleException.
Solutions
- Read the wrapped cause (e) in the log — it names the actual failing target step/field
- Open the Meta Inject mapping grid and remove/fix entries whose target step or target field no longer exists in the child transformation
- Re-generate the mapping from the source and target transformations so field names and types are current
- Validate source field types against the target step meta (e.g. string vs integer) and add Select Values conversions if needed
Example fix
// before: mapping to a field removed from the child step
entry.setTargetField('oldFieldName');
// after
entry.setTargetField('currentFieldName'); // per current child .ktr step meta Defensive patterns
Strategy: try-catch
Validate before calling
// Validate mapping targets against the child transformation before injection
for (MetaInjectTransformationTargetTarget t : targets) {
StepMeta step = child.findStep(t.getTargetStep());
if (step == null) throw new IllegalStateException('Unknown target step: ' + t.getTargetStep());
// verify field exists in step meta via step.getStepMetaInterface() reflection if needed
} Type guard
boolean mappingTargetsValid(TransMeta child, java.util.Map<String,String> targetSteps) {
return targetSteps.values().stream().allMatch(n -> child.findStep(n) != null);
} Try / catch
try {
// execute meta injection
} catch (KettleException e) {
if (e.getMessage().contains('Unexpected error occurred while injecting metadata')) {
log.error('Injection mapping mismatch; cause: ' + e.getCause(), e);
// regenerate mapping and retry once
} else throw e;
} Prevention
- Regenerate the mapping grid after any child .ktr change
- Check source/target field types before injection (add Select Values conversions)
- Avoid null values in injection source rows
- Store the mapping definition alongside the child .ktr in version control
When it happens
Trigger: During processRow -> oldInjection: an injection mapping references a target step or target field that doesn't exist in the child transformation, or setting a field on the step meta fails (type/ reflection/ NPE), caught by the catch(Exception) inside the entry loop.
Common situations: Child .ktr changed so mapped target fields no longer exist; injection source rows have wrong types for the target field; mapping CSV/Excel defined against an older transformation version; null source values injected into primitives.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Error inject property
- No setter defined for
- Property not found
- Can't create object
- Clone not supported for
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/2956620ca1e0278c.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/meta-inject/impl/src/main/java/org/pentaho/di/trans/steps/metainject/MetaInject.java:543
try {
List<StepInjectionMetaEntry> rowEntries = metaEntries.getDetails().get( i ).getDetails();
for ( StepInjectionMetaEntry rowEntry : rowEntries ) {
// We have to look up the sources for these targets again in the target-2-source mapping
// That is because we only want handle this as few times as possible...
//
SourceStepField detailSource = findDetailSource( targetMap, targetStep, rowEntry.getKey() );
if ( detailSource != null ) {
setEntryValueIfFieldExists( rowEntry, row, detailSource );
} else {
if ( log.isDetailed() ) {
logDetailed( "No detail source found for key: " + rowEntry.getKey() + " and target step: "
+ targetStep );
}
}
}
} catch ( Exception e ) {
throw new KettleException( "Unexpected error occurred while injecting metadata", e );
}
}
if ( log.isDetailed() ) {
logDetailed( "injected entry: " + entry );
}
}
// End of TopLevel/Detail if block
} else {
if ( log.isDetailed() ) {
logDetailed( "entry not found: " + target.getAttributeKey() );
}
}
} else {
if ( log.isDetailed() ) {
logDetailed( "No rows found for source step: " + source.getStepname() );
}
}View on GitHub (pinned to f3058517a1)