pentaho/pentaho-kettle · error · KettleJobException

JobEntrySetVariables.Error.UnableSetVariableParentJob

Error message

JobEntrySetVariables.Error.UnableSetVariableParentJob

What it means

This KettleJobException is thrown in execute() for the 'grand-parent job' variable scope (VARIABLE_TYPE_GRAND_PARENT_JOB): the variable was set on the parent job, but the parent job itself has no parent Job, so the requested scope cannot be honored. The message names the variable that could not be set at the grand-parent level.

Solutions

  1. Change the variable scope to 'Valid in the parent job' (or root job) to match the actual nesting depth
  2. Nest the job one level deeper so a grand-parent Job exists
  3. Refactor to pass the value via result rows/parameters instead of relying on grand-parent scope

Example fix

// before
// Variable scope: 'Valid in the grand-parent job' in a job nested only 1 level
// after
// Variable scope: 'Valid in the parent job'
Defensive patterns

Strategy: validation

Validate before calling

// confirm the job actually has a grand-parent before grand-parent scope
Job parent = job.getParentJob();
if ("GRAND_PARENT_JOB".equals(scope) && (parent == null || parent.getParentJob() == null)) {
  throw new IllegalStateException("Grand-parent variable scope requires 2 levels of job nesting");
}

Try / catch

try {
  result = jobEntry.execute(result, nr);
} catch (KettleJobException e) {
  if (e.getMessage().contains("UnableSetVariableParentJob")) {
    logError("No grand-parent job exists; adjust the variable scope to parent job");
  }
}

Prevention

When it happens

Trigger: Variable type set to 'Valid in the grand-parent job' while the executing job is only nested one level deep (parentJob.getParentJob() == null) - i.e. there is no grand-parent to receive the variable.

Common situations: Job nesting changed (a sub-job was promoted to run directly under the root job, removing the grand-parent level); someone set the wrong scope in the dialog; reusing a copied entry that assumed deeper nesting.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/job/entries/setvariables/JobEntrySetVariables.java:342

              }
              parentJob.setVariable( varname, value );

            } else {
              throw new KettleJobException( BaseMessages.getString(
                PKG, "JobEntrySetVariables.Error.UnableSetVariableCurrentJob", varname ) );
            }
            break;

          case VARIABLE_TYPE_PARENT_JOB:
            setVariable( varname, value );

            if ( parentJob != null ) {
              parentJob.setVariable( varname, value );
              Job gpJob = parentJob.getParentJob();
              if ( gpJob != null ) {
                gpJob.setVariable( varname, value );
              } else {
                throw new KettleJobException( BaseMessages.getString(
                  PKG, "JobEntrySetVariables.Error.UnableSetVariableParentJob", varname ) );
              }
            } else {
              throw new KettleJobException( BaseMessages.getString(
                PKG, "JobEntrySetVariables.Error.UnableSetVariableCurrentJob", varname ) );
            }
            break;

          default:
            break;
        }

        // ok we can process this line
        if ( log.isDebug() ) {
          logDebug( BaseMessages.getString( PKG, "JobEntrySetVariables.Log.SetVariableToValue", varname, value ) );
        }
      }
    } catch ( Exception e ) {

View on GitHub (pinned to f3058517a1)