{"record":{"id":"5d668df360905161","repo":"pentaho/pentaho-kettle","slug":"couldn-t-convert-string-string-to-an-internet-address","errorCode":null,"errorMessage":" : couldn't convert string [\" + string + \"] to an internet address","messagePattern":" : couldn't convert string \\[\" \\+ string \\+ \"\\] 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":285,"sourceCode":"      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    }\n  }\n\n  protected synchronized String convertInternetAddressToString( InetAddress inetAddress ) throws KettleValueException {\n\n    if ( inetAddress == null ) {\n      return null;\n    }\n\n    return inetAddress.getHostAddress();\n  }\n\n  @Override\n  public Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,\n    int trim_type ) throws KettleValueException {\n    // null handling and conversion of value to null\n    //","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaInternetAddress.java#L267-L303","documentation":"convertStringToInternetAddress() parses a string via InetAddress.getByName(); any parse/resolution failure is wrapped in KettleValueException 'couldn't convert string [...] to an internet address'. Note the source string is included in the message.","triggerScenarios":"getString()/getInternetAddress()/getValueFromResultSet/convertData encountering a string that is not a valid IP literal (getByName with an unresolvable hostname also throws). Whitespace or locale-specific formatting in the input also triggers this.","commonSituations":"CSV/log fields containing hostnames, empty strings, or malformed addresses ('999.1.1.1', '::gg::'); DNS-less environments where getByName cannot resolve host names; trailing spaces in fixed-width file columns.","solutions":["Clean/trim the input and confirm it is a valid IP literal (or resolvable host) before conversion","Set the field type to String instead of Internet Address for non-IP values","Pre-validate with a regex/IP parse in a modified Java Script step or filter invalid rows","Catch KettleValueException and use Kettle error handling to send bad rows aside"],"exampleFix":"// before\nrow[ipIdx] = inetMeta.convertData(strMeta, row[hostIdx]);\n// after\nString s = strMeta.getString(row[hostIdx]).trim();\nif (!s.matches(\"[0-9a-fA-F:.]+\")) row[ipIdx] = null;\nelse row[ipIdx] = inetMeta.convertData(strMeta, s);","handlingStrategy":"validation","validationCode":"String s = stringMeta.getString(v);\nif (s == null || !s.trim().matches(\"([0-9]{1,3}\\\\.){3}[0-9]{1,3}|[0-9a-fA-F:]+\")) { /* invalid, skip or null */ }","typeGuard":"boolean looksLikeIp(String s){ return s != null && s.trim().matches(\"([0-9]{1,3}\\\\.){3}[0-9]{1,3}|[0-9a-fA-F:]+\") && !s.trim().isEmpty(); }","tryCatchPattern":"try { addr = inetMeta.convertData(strMeta, s); } catch (KettleValueException e) { /* bad literal: log s and default */ }","preventionTips":["Trim inputs before conversion","Reject hostnames unless DNS is guaranteed available","Pre-filter malformed address literals","Use Kettle error handling for unparseable rows"],"tags":["inetaddress","string-parsing","ipv6","kettle"],"backgroundTag":"invalid-argument-format","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"}