pentaho/pentaho-kettle · error · RuntimeException

The function call fireToDB requires 2 arguments.

Error message

The function call fireToDB requires 2 arguments.

What it means

fireToDB(dbName, sql) accepts exactly two arguments — the connection name string and the SQL string. Any other argument count throws this RuntimeException, because the function indexes ArgList[0] and ArgList[1] unconditionally otherwise.

Solutions

  1. Call with exactly two string arguments: fireToDB('ConnName', 'SQL STATEMENT').
  2. Embed literal values into the SQL string instead of passing extra parameters (with care for SQL injection).
  3. Use a Table Input/Execute SQL step with parameters for parameterized queries.

Example fix

// before
fireToDB('MyConn', sql, id);
// after
fireToDB('MyConn', 'DELETE FROM logs WHERE id = ' + id);
Defensive patterns

Strategy: validation

Validate before calling

if (typeof connName === 'string' && typeof sql === 'string') { fireToDB(connName, sql); }

Type guard

function fireToDBSafe(c, s) { return (typeof c === 'string' && typeof s === 'string') ? fireToDB(c, s) : null; }

Try / catch

try { fireToDB(connName, sql); } catch (e) { if (/fireToDB requires 2 arguments/.test(String(e))) { /* fix arity */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling fireToDB with one argument or three or more, e.g. fireToDB('Conn') or fireToDB('Conn', sql, param).

Common situations: Trying to pass bind parameters as extra arguments (not supported); forgetting the SQL argument; confusion with other SQL helpers that take more parameters.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:529

              Object[] objRow = new Object[columnCount];
              for ( int i = 0; i < columnCount; i++ ) {
                objRow[i] = rs.getObject( i + 1 );
              }
              list.add( objRow );
            }
            Object[][] resultArr = new Object[list.size()][];
            list.toArray( resultArr );
            db.close();
            return resultArr;
          }
        } catch ( Exception er ) {
          throw new RuntimeException( er.toString() );
        }
      } catch ( Exception e ) {
        throw new RuntimeException( e.toString() );
      }
    } else {
      throw new RuntimeException( "The function call fireToDB requires 2 arguments." );
    }
    return oRC;
  }

  public static Object dateDiff( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    if ( ArgList.length == 3 ) {
      try {
        if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
          return new Double( Double.NaN );
        } else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
          return undefinedValue;
        } else {
          java.util.Date dIn1 = (java.util.Date) ArgList[0];
          java.util.Date dIn2 = (java.util.Date) ArgList[1];
          String strType = ( (String) ArgList[2] ).toLowerCase();
          int iRC = 0;

View on GitHub (pinned to f3058517a1)