{"record":{"id":"076f68badf0c005a","repo":"pentaho/pentaho-kettle","slug":"unable-to-convert-an-integer-to-an-internet-address","errorCode":null,"errorMessage":"Unable to convert an Integer to an internet address","messagePattern":"Unable to convert an Integer to an internet address","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaInternetAddress.java","lineNumber":269,"sourceCode":"      return null;\n    }\n\n    byte[] addr;\n    if ( l >= Math.pow( 256, 4 ) ) {\n      addr = new byte[16];\n    } else {\n      addr = new byte[4];\n    }\n\n    for ( int i = 0; i < addr.length; i++ ) {\n      long mask = 0xFF << ( i * 8 );\n      addr[addr.length - 1 - i] = (byte) ( ( l & mask ) >> ( 8 * i ) );\n    }\n\n    try {\n      return InetAddress.getByAddress( addr );\n    } catch ( Exception e ) {\n      throw new KettleValueException( \"Unable to convert an Integer to an internet address\", e );\n    }\n  }\n\n  protected synchronized InetAddress convertStringToInternetAddress( String string ) throws KettleValueException {\n    // See if trimming needs to be performed before conversion\n    //\n    string = Const.trimToType( string, getTrimType() );\n\n    if ( Utils.isEmpty( string ) ) {\n      return null;\n    }\n\n    try {\n      return InetAddress.getByName( string );\n    } catch ( Exception e ) {\n      throw new KettleValueException( toString()\n        + \" : couldn't convert string [\" + string + \"] to an internet address\", e );\n    }","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaInternetAddress.java#L251-L287","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the source field actually contains integer-encoded IP addresses before assigning type Internet Address","Keep the field as Integer/String and convert explicitly, or correct the field type mapping in the input step","Catch KettleValueException and route bad rows to an error handling stream"],"exampleFix":"// before\nrow[ipFieldIdx] = inetMeta.convertData(intMeta, row[numFieldIdx]);\n// after\nlong v = intMeta.getInteger(row[numFieldIdx]);\nif (v < 0 || v > 0xFFFFFFFFL) throw new KettleException(\"Not an IPv4 int: \" + v);\nrow[ipFieldIdx] = inetMeta.convertData(intMeta, row[numFieldIdx]);","handlingStrategy":"validation","validationCode":"long v = intMeta.getInteger(data);\nif (v < 0 || v > 0xFFFFFFFFL) throw new KettleException(\"value is not an integer-encoded IPv4 address\");","typeGuard":"boolean isEncodableIpv4(Long v){ return v != null && v >= 0 && v <= 0xFFFFFFFFL; }","tryCatchPattern":"try { addr = inetMeta.convertData(intMeta, data); } catch (KettleValueException e) { /* route to error handling */ }","preventionTips":["Confirm source fields truly contain integer-encoded IPs","Use Kettle error handling streams for bad rows","Keep numeric ID fields typed as Integer, not Internet Address"],"tags":["inetaddress","type-conversion","integer","kettle"],"backgroundTag":"type-mismatch","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}