Skip to content

Commit

Permalink
Only check for parse errors
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-gr committed Oct 14, 2020
1 parent 75df6ef commit 7b4df27
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions x-pack/filebeat/input/httpjson/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,10 @@ func (dc *dateCursorConfig) Validate() error {
}

const knownTimestamp = 1602601228 // 2020-10-13T15:00:28+00:00 RFC3339
knownDate := time.Unix(knownTimestamp, 0).UTC()

// if we can't get back the same date from Format than from Parse
// it is because the defined format is invalid
dateStr := time.Unix(knownTimestamp, 0).UTC().Format(dc.DateFormat)
if t, err := time.Parse(dc.DateFormat, dateStr); err != nil || t.Unix() != knownTimestamp {
dateStr := knownDate.Format(dc.DateFormat)
if _, err := time.Parse(dc.DateFormat, dateStr); err != nil {
return errors.New("invalid configuration: date_format is not a valid date layout")
}

Expand Down

0 comments on commit 7b4df27

Please sign in to comment.