{"record":{"id":"25ff61a3e19d741d","repo":"pentaho/pentaho-kettle","slug":"error-invalid-date-being-set-as-build-date","errorCode":null,"errorMessage":"Error:  Invalid date being set as build date","messagePattern":"Error:  Invalid date being set as build date","errorType":"exception","errorClass":"KettleVersionException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/version/BuildVersion.java","lineNumber":148,"sourceCode":"    }\n\n    return null;\n\n  }\n\n  /**\n   * @param buildDate\n   *          the buildDate to set\n   */\n  public void setBuildDate( String buildDate ) throws KettleVersionException {\n    // don't let them set a bogus date...\n    String tempDate = this.buildDate;\n    this.buildDate = buildDate;\n    Date testDate = getBuildDateAsLocalDate();\n    if ( testDate == null ) {\n      // reset it to the old date...\n      this.buildDate = tempDate;\n      throw new KettleVersionException( \"Error:  Invalid date being set as build date\" ); // this should be\n                                                                                          // localizable... next\n      // pass....\n    }\n  }\n\n  /**\n   * @return the version\n   */\n  public String getVersion() {\n    return version;\n  }\n\n  /**\n   * @param revision\n   *          the version to set\n   */\n  public void setVersion( String version ) {\n    this.version = version;","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/version/BuildVersion.java#L130-L166","documentation":"BuildVersion.setBuildDate validates the candidate build-date string by parsing it via getBuildDateAsLocalDate(); if parsing yields null the new value is rejected, the previous value restored, and KettleVersionException 'Error: Invalid date being set as build date' is thrown. This protects the version metadata from unparseable date strings.","triggerScenarios":"Calling setBuildDate(String) with a string not matching the expected date format that getBuildDateAsLocalDate can parse (null, empty, or wrong-pattern dates).","commonSituations":"Custom build scripts injecting a bad build date property; localization/manifest changes altering the date format; manually edited build version resources.","solutions":["Pass a date string in the exact format getBuildDateAsLocalDate expects (as produced by the standard build process).","Inspect the value being set — log it before calling setBuildDate — and fix the build configuration/manifest that produced it.","Pre-validate with a SimpleDateFormat/DateTimeFormatter parse using the same pattern before calling the setter.","If the date is unknown, leave the field at its default rather than setting an invalid string."],"exampleFix":"// before\nbuildVersion.setBuildDate( rawDate ); // may throw\n// after\nif ( BuildVersion.parseSafely( rawDate ) != null ) {\n  buildVersion.setBuildDate( rawDate );\n}","handlingStrategy":"validation","validationCode":"SimpleDateFormat fmt = new SimpleDateFormat( BuildVersion.DATE_PATTERN );\nfmt.setLenient( false );\ntry { fmt.parse( candidate ); } catch ( ParseException e ) { candidate = null; /* don't call setter */ }","typeGuard":"boolean isValidBuildDate( String s ) {\n  if ( s == null ) return false;\n  try { new SimpleDateFormat( BuildVersion.DATE_PATTERN ).parse( s ); return true; } catch ( ParseException e ) { return false; }\n}","tryCatchPattern":"try {\n  buildVersion.setBuildDate( value );\n} catch ( KettleVersionException e ) {\n  log.error( \"Rejected build date: \" + value );\n}","preventionTips":["Generate build dates with the same formatter the library uses to parse them","Never hand-edit build version resources","Log candidate values before setting"],"tags":["invalid-date-format","version-metadata","java"],"backgroundTag":"invalid-date-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"}