{"record":{"id":"6e3a3c9e60a07fef","repo":"pentaho/pentaho-kettle","slug":"not-a-valid-default-value-defaultvalue-for-data-type-type","errorCode":null,"errorMessage":"Not a valid default value \" + defaultValue + \" for data type \" + type + \" - \" + exception.getMessage()","messagePattern":"Not a valid default value \" \\+ defaultValue \\+ \" for data type \" \\+ type \\+ \" - \" \\+ exception\\.getMessage\\(\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/output/PentahoAvroOutputFormat.java","lineNumber":278,"sourceCode":"          return Float.parseFloat( defaultValue );\n        case DOUBLE:\n          return Double.parseDouble( defaultValue );\n        case LONG:\n        case INTEGER:\n          return Long.parseLong( defaultValue );\n        case DECIMAL:\n          return getDecimalTypeForDefaultValue( defaultValue );\n        case STRING:\n          return String.valueOf( defaultValue );\n        case BYTES:\n          return defaultValue.getBytes();\n        case TIMESTAMP_MILLIS:\n          return getTimeStampTypeForDefaultValue( defaultValue );\n        default:\n          return defaultValue;\n      }\n    } catch ( NumberFormatException | ParseException exception ) {\n      throw new IllegalArgumentException( \"Not a valid default value \" + defaultValue + \" for data type \" + type + \" - \" + exception.getMessage());\n    }\n\n  }\n\n  /**\n   * Converts the default value as Big decimal value and return bytes.\n   * <p>\n   * @param defaultValue The default value provided.\n   * @return The byte array of big decimal value.\n   */\n  private byte[] getDecimalTypeForDefaultValue( String defaultValue ) {\n    BigDecimal bigDecimalValue = new BigDecimal( defaultValue );\n    return bigDecimalValue.unscaledValue().toByteArray();\n  }\n\n  /**\n   * Converts the default value to Date.\n   *","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/output/PentahoAvroOutputFormat.java#L260-L296","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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)","Use ValueMetaBase.DEFAULT_DATE_PARSE_MASK / DEFAULT_TIMESTAMP_PARSE_MASK formats for date/timestamp fields","Verify the Avro type assigned to the field matches the intended default (type/default mismatch)","Test the value with SimpleDateFormat.parse or Long.parseLong before saving the transformation","Clear the default value if none is required"],"exampleFix":"// before (unparseable)\nfield.setDefault( \"31-12-2024\" ); // fails for yyyy-MM-dd mask\n// after\nfield.setDefault( \"2024-12-31\" ); // matches ValueMetaBase.DEFAULT_DATE_PARSE_MASK","handlingStrategy":"validation","validationCode":"// test default parseability before configuring\ntry { new java.text.SimpleDateFormat( \"yyyy/MM/dd HH:mm:ss\" ).parse( defaultValue ); }\ncatch ( ParseException e ) { throw new IllegalArgumentException( \"Default value not in expected format: \" + defaultValue ); }","typeGuard":"boolean isParsableDefault( String v, AvroSpec.DataType t ) { try { return mapDefaultValuesToDataTypes( v, t ) != null; } catch ( Exception e ) { return false; } }","tryCatchPattern":"try { Object o = avroOutputFormat.defaultObject( type ); }\ncatch ( IllegalArgumentException e ) { log.warn( \"Bad default value: \" + e.getMessage() ); fallBackToNullDefault(); }","preventionTips":["Enter defaults in the documented masks (yyyy/MM/dd HH:mm:ss for dates/timestamps)","Match the default format to the field's Avro type before saving","Watch out for locale decimal separators in numeric defaults","Clear defaults you don't need instead of leaving placeholder text"],"tags":["avro","parsing","default-value","configuration"],"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"}