pentaho/pentaho-kettle · error · KettleValueException

Couldn't convert string to number

Error message

Couldn't convert string to number 

What it means

Thrown when the legacy Value str2num() conversion fails: DecimalFormat.parse() threw while converting the string value to a double. The message is enriched with the conversion pattern, decimal, grouping and currency settings in effect, which identify the mismatch between the string and the formatter configuration.

Solutions

  1. Align the conversion mask, decimal symbol, grouping symbol and currency symbol with the actual string data
  2. Strip stray characters or whitespace from the input string before conversion
  3. Check the reported pattern/decimal/grouping appended to the message to spot the misconfiguration
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3238 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/3eca5dbd25abc706. Report an issue: GitHub.

Appendix: source

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

          }
          try {
            df.setDecimalFormatSymbols( dfs );
            setValue( df.parse( getString() ).doubleValue() );
          } catch ( Exception e ) {
            String message = "Couldn't convert string to number " + e.toString();
            if ( !Utils.isEmpty( pattern ) ) {
              message += " pattern=" + pattern;
            }
            if ( !Utils.isEmpty( decimal ) ) {
              message += " decimal=" + decimal;
            }
            if ( !Utils.isEmpty( grouping ) ) {
              message += " grouping=" + grouping.charAt( 0 );
            }
            if ( !Utils.isEmpty( currency ) ) {
              message += " currency=" + currency;
            }
            throw new KettleValueException( message );
          }
        }
      } else {
        throw new KettleValueException( "Function STR2NUM works only on strings" );
      }
    }
    return this;
  }

  public Value dat2num() throws KettleValueException {
    if ( isNull() ) {
      setType( VALUE_TYPE_INTEGER );
      return this;
    }

    if ( getType() == VALUE_TYPE_DATE ) {
      if ( getString() == null ) {
        setNull();

View on GitHub (pinned to f3058517a1)