pentaho/pentaho-kettle · error · IllegalArgumentException

Not a valid default value " + defaultValue + " for data…

Error message

Not a valid default value " + defaultValue + " for data type " + type + " - " + exception.getMessage()

What it means

IllegalArgumentException thrown by PentahoAvroOutputFormat.mapDefaultValuesToDataTypes when the string default value for an Avro field cannot be parsed (NumberFormatException or ParseException) into the field's declared data type.

Solutions

  1. Fix the default value string in the step's field configuration to match the declared type (e.g. '123' for numeric, 'yyyy-MM-dd' for dates)
  2. Use ValueMetaBase.DEFAULT_DATE_PARSE_MASK / DEFAULT_TIMESTAMP_PARSE_MASK formats for date/timestamp fields
  3. Verify the Avro type assigned to the field matches the intended default (type/default mismatch)
  4. Test the value with SimpleDateFormat.parse or Long.parseLong before saving the transformation
  5. Clear the default value if none is required

Example fix

// before (unparseable)
field.setDefault( "31-12-2024" ); // fails for yyyy-MM-dd mask
// after
field.setDefault( "2024-12-31" ); // matches ValueMetaBase.DEFAULT_DATE_PARSE_MASK
Defensive patterns

Strategy: validation

Validate before calling

// test default parseability before configuring
try { new java.text.SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" ).parse( defaultValue ); }
catch ( ParseException e ) { throw new IllegalArgumentException( "Default value not in expected format: " + defaultValue ); }

Type guard

boolean isParsableDefault( String v, AvroSpec.DataType t ) { try { return mapDefaultValuesToDataTypes( v, t ) != null; } catch ( Exception e ) { return false; } }

Try / catch

try { Object o = avroOutputFormat.defaultObject( type ); }
catch ( IllegalArgumentException e ) { log.warn( "Bad default value: " + e.getMessage() ); fallBackToNullDefault(); }

Prevention

When it happens

Trigger: Calling mapDefaultValuesToDataTypes (via defaultObject) with a defaultValue string that fails parsing for the given AvroSpec.DataType — e.g. 'abc' for a numeric type, '2025-13-45' for date/timestamp types.

Common situations: Typing a human-readable date/time string that doesn't match the expected parse mask; leaving a placeholder or empty text in the Default value column; locale differences making decimal separators unparseable; copy-pasting default values between fields of different types.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/output/PentahoAvroOutputFormat.java:278

          return Float.parseFloat( defaultValue );
        case DOUBLE:
          return Double.parseDouble( defaultValue );
        case LONG:
        case INTEGER:
          return Long.parseLong( defaultValue );
        case DECIMAL:
          return getDecimalTypeForDefaultValue( defaultValue );
        case STRING:
          return String.valueOf( defaultValue );
        case BYTES:
          return defaultValue.getBytes();
        case TIMESTAMP_MILLIS:
          return getTimeStampTypeForDefaultValue( defaultValue );
        default:
          return defaultValue;
      }
    } catch ( NumberFormatException | ParseException exception ) {
      throw new IllegalArgumentException( "Not a valid default value " + defaultValue + " for data type " + type + " - " + exception.getMessage());
    }

  }

  /**
   * Converts the default value as Big decimal value and return bytes.
   * <p>
   * @param defaultValue The default value provided.
   * @return The byte array of big decimal value.
   */
  private byte[] getDecimalTypeForDefaultValue( String defaultValue ) {
    BigDecimal bigDecimalValue = new BigDecimal( defaultValue );
    return bigDecimalValue.unscaledValue().toByteArray();
  }

  /**
   * Converts the default value to Date.
   *

View on GitHub (pinned to f3058517a1)