pentaho/pentaho-kettle · error · KettleValueException

Function DECODE can't have arguments!

Error message

Function DECODE can't have  arguments!

What it means

Validation of the DECODE function's argument list: it requires an odd count of at least 3 arguments (search/result pairs plus a default). The actual args.length, interpolated into the message, is even or below 3, so the if/else ladder of the legacy Value decode() cannot be evaluated.

Solutions

  1. Pass an odd number (3, 5, 7, ...) of arguments to DECODE: pairs of search/value plus a final default
  2. Remove or add arguments so args.length % 2 == 1 and args.length >= 3
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3333 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3333

    // Limit to 3, 5, 7, 9, ... arguments

    if ( args.length >= 3 && ( args.length % 2 ) == 1 ) {
      i = 0;
      found = false;
      while ( i < args.length - 1 && !found ) {
        if ( this.equals( args[i] ) ) {
          setValue( args[i + 1] );
          found = true;
        }
        i += 2;
      }
      if ( !found ) {
        setValue( args[args.length - 1] );
      }
    } else {
      // ERROR with nr of arguments
      throw new KettleValueException( "Function DECODE can't have " + args.length + " arguments!" );
    }

    return this;
  }

  // implement the IF function, arguments in args[]
  // IF( <condition>, <then value>, <else value>)
  public Value v_if( Value[] args ) throws KettleValueException {
    if ( getType() == VALUE_TYPE_BOOLEAN ) {
      if ( args.length == 1 ) {
        if ( getBoolean() ) {
          setValue( args[0] );
        } else {
          setNull();
        }
      } else if ( args.length == 2 ) {
        if ( getBoolean() ) {
          setValue( args[0] );

View on GitHub (pinned to f3058517a1)