pentaho/pentaho-kettle · error · KettleValueException

Unable to convert an Integer to an internet address

Error message

Unable to convert an Integer to an internet address

What it means

convertIntegerToInternetAddress() packs a long into bytes and calls InetAddress.getByAddress(). If that JDK call fails (malformed address length/content), the library wraps the failure in KettleValueException 'Unable to convert an Integer to an internet address'.

Solutions

  1. Verify the source field actually contains integer-encoded IP addresses before assigning type Internet Address
  2. Keep the field as Integer/String and convert explicitly, or correct the field type mapping in the input step
  3. Catch KettleValueException and route bad rows to an error handling stream

Example fix

// before
row[ipFieldIdx] = inetMeta.convertData(intMeta, row[numFieldIdx]);
// after
long v = intMeta.getInteger(row[numFieldIdx]);
if (v < 0 || v > 0xFFFFFFFFL) throw new KettleException("Not an IPv4 int: " + v);
row[ipFieldIdx] = inetMeta.convertData(intMeta, row[numFieldIdx]);
Defensive patterns

Strategy: validation

Validate before calling

long v = intMeta.getInteger(data);
if (v < 0 || v > 0xFFFFFFFFL) throw new KettleException("value is not an integer-encoded IPv4 address");

Type guard

boolean isEncodableIpv4(Long v){ return v != null && v >= 0 && v <= 0xFFFFFFFFL; }

Try / catch

try { addr = inetMeta.convertData(intMeta, data); } catch (KettleValueException e) { /* route to error handling */ }

Prevention

When it happens

Trigger: Calling getInternetAddress()/convertData/convertNumberToInternetAddress/convertBigNumberToInternetAddress with an integer that does not decode to a valid 4-byte (or expected-length) address, or a JVM where InetAddress resolution fails unexpectedly.

Common situations: Numeric fields from a database holding non-address integers (IDs, epoch values) accidentally mapped into Internet Address fields; CSV numeric columns typed as Internet Address in the field definition.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaInternetAddress.java:269

      return null;
    }

    byte[] addr;
    if ( l >= Math.pow( 256, 4 ) ) {
      addr = new byte[16];
    } else {
      addr = new byte[4];
    }

    for ( int i = 0; i < addr.length; i++ ) {
      long mask = 0xFF << ( i * 8 );
      addr[addr.length - 1 - i] = (byte) ( ( l & mask ) >> ( 8 * i ) );
    }

    try {
      return InetAddress.getByAddress( addr );
    } catch ( Exception e ) {
      throw new KettleValueException( "Unable to convert an Integer to an internet address", e );
    }
  }

  protected synchronized InetAddress convertStringToInternetAddress( String string ) throws KettleValueException {
    // See if trimming needs to be performed before conversion
    //
    string = Const.trimToType( string, getTrimType() );

    if ( Utils.isEmpty( string ) ) {
      return null;
    }

    try {
      return InetAddress.getByName( string );
    } catch ( Exception e ) {
      throw new KettleValueException( toString()
        + " : couldn't convert string [" + string + "] to an internet address", e );
    }

View on GitHub (pinned to f3058517a1)