pentaho/pentaho-kettle · warning · RuntimeException

Alert dialog cancelled by user.

Error message

Alert dialog cancelled by user.

What it means

The ScriptValuesMod `Alert(message)` function shows a modal message box via the Spoon UI (SpoonFactory.getInstance().messageBox). If the user closes/cancels the dialog instead of confirming, the function throws this RuntimeException to abort the transformation run.

Solutions

  1. Re-run and click OK instead of cancelling the dialog
  2. Remove or gate the Alert() call before production/scheduled runs (it requires interactive UI)
  3. Replace Alert with a log statement (e.g. write to a field or use the 'Write To Log' step) for non-interactive use

Example fix

// before
Alert('Row: ' + rowNum);
// after
writeToLog('Row: ' + rowNum); // or remove the call
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the step only runs interactively in Spoon
if (SpoonFactory.getInstance() == null) {
  // headless run: skip Alert, log instead
}

Type guard

function canAlert() { return SpoonFactory.getInstance() != null; }

Try / catch

try {
  Alert('message');
} catch (e) {
  if (String(e).indexOf('Alert dialog cancelled') !== -1) {
    // user cancelled: treat as abort or continue per requirements
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling Alert('some message') inside a JavaScript step while running in Spoon, and the user clicks Cancel/closes the alert dialog instead of OK.

Common situations: Interactive debugging in Spoon where a tester dismisses the box; scheduled/headless executions where spoon is null — note in that case the function silently returns '' instead of throwing; a user misunderstanding that Cancel aborts the step.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1573

        return objForReplace;
      } else {
        throw Context.reportRuntimeError( "The function call replace is not valid (wrong number of arguments)" );
      }
    } catch ( Exception e ) {
      throw Context.reportRuntimeError( "Function call replace is not valid : " + e.getMessage() );
    }
  }

  // Implementation of the JS AlertBox
  public static String Alert( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {

    SpoonInterface spoon = SpoonFactory.getInstance();
    if ( ArgList.length == 1 && spoon != null ) {
      String strMessage = Context.toString( ArgList[0] );
      boolean ok = spoon.messageBox( strMessage, "Alert", true, Const.INFO );
      if ( !ok ) {
        throw new RuntimeException( "Alert dialog cancelled by user." );
      }
    }

    return "";
  }

  // Setting EnvironmentVar
  public static void setEnvironmentVar( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    String sArg1 = "";
    String sArg2 = "";
    if ( ArgList.length == 2 ) {
      try {
        sArg1 = Context.toString( ArgList[0] );
        sArg2 = Context.toString( ArgList[1] );
        System.setProperty( sArg1, sArg2 );
      } catch ( Exception e ) {
        throw Context.reportRuntimeError( e.toString() );

View on GitHub (pinned to f3058517a1)