{"record":{"id":"f95c513986d8079e","repo":"pentaho/pentaho-kettle","slug":"salesforceinput-error-emptystartdateorenddate","errorCode":"SalesforceInput.Error.EmptyStartDateOrEndDate","errorMessage":"SalesforceInput.Error.EmptyStartDateOrEndDate","messagePattern":"SalesforceInput\\.Error\\.EmptyStartDateOrEndDate","errorType":"error_code","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java","lineNumber":180,"sourceCode":"  /**\n   *\n   * @see #setQueryAll(boolean)\n   */\n  @Deprecated\n  public void queryAll( boolean value ) {\n    setQueryAll( value );\n  }\n\n  public void setQueryAll( boolean value ) {\n    this.queryAll = value;\n  }\n\n  public void setCalendar( int recordsFilter, GregorianCalendar startDate, GregorianCalendar endDate ) throws KettleException {\n    this.startDate = startDate;\n    this.endDate = endDate;\n    this.recordsFilter = recordsFilter;\n    if ( this.startDate == null || this.endDate == null ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.Error.EmptyStartDateOrEndDate\" ) );\n    }\n    if ( this.startDate.getTime().compareTo( this.endDate.getTime() ) >= 0 ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.Error.WrongDates\" ) );\n    }\n    // Calculate difference in days\n    long diffDays =\n      ( this.endDate.getTime().getTime() - this.startDate.getTime().getTime() ) / ( 24 * 60 * 60 * 1000 );\n    if ( diffDays > 30 ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.Error.StartDateTooOlder\" ) );\n    }\n  }\n\n  public void setSQL( String sql ) {\n    this.sql = sql;\n  }\n\n  public void setFieldsList( String fieldsList ) {\n    this.fieldsList = fieldsList;","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java#L162-L198","documentation":"SalesforceConnection.setCalendar() throws this KettleException when either startDate or endDate is null. The method requires both calendar bounds to be set before it validates the date range for Salesforce filtered queries. It is a fail-fast precondition check so null dates never reach the SOAP query construction.","triggerScenarios":"Calling setCalendar(recordsFilter, startDate, endDate) with startDate == null or endDate == null, e.g. when the step's date fields were not populated or variables resolved to empty.","commonSituations":"Salesforce Input step configured with 'Records since last modified/created between dates' but one of the start/end date fields left blank in the dialog; a variable like ${START_DATE} not defined at runtime; tests intentionally passing null to verify the check.","solutions":["Set both startDate and endDate in the Salesforce Input step dialog (or via variables) before running the transformation.","In code, construct both GregorianCalendar instances with non-null Date values before calling setCalendar.","If dates come from user input or parameters, validate they parse to a Date before passing them in.","If you don't need date-range filtering, use a different recordsFilter (e.g. RECORDS_FILTER_ALL) instead of passing null dates."],"exampleFix":"// before\nconn.setCalendar(SalesforceConnectionUtils.RECORDS_FILTER_DATE_RANGE, startCal, null);\n// after\nif (startCal == null || endCal == null) {\n  throw new IllegalArgumentException(\"startDate and endDate are required\");\n}\nconn.setCalendar(SalesforceConnectionUtils.RECORDS_FILTER_DATE_RANGE, startCal, endCal);","handlingStrategy":"validation","validationCode":"if (startCal == null || endCal == null) {\n  throw new IllegalArgumentException(\"setCalendar requires non-null startDate and endDate\");\n}","typeGuard":"boolean hasBothDates = java.util.Objects.nonNull(startCal) && java.util.Objects.nonNull(endCal);","tryCatchPattern":"try {\n  conn.setCalendar(recordsFilter, startCal, endCal);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"EmptyStartDateOrEndDate\")) {\n    logError(\"Start/end date not configured\");\n  }\n}","preventionTips":["Validate both date fields in the step dialog before save/run.","Resolve variable-based dates early and fail fast on unresolvable variables.","Only call setCalendar for the filters that require dates."],"tags":["salesforce","date-validation","null-argument","kettle"],"backgroundTag":"null-argument","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"}