Billionmail/BillionMail · error

invalid start_date: %v

Error message

invalid start_date: %v

What it means

getLogFilesInRange parses start_date with layout '2006-01-02'; when time.Parse fails it returns 'invalid start_date: %v'. The wrapped value is Go's parsing error, showing the offending value and expected layout.

Source

Thrown at core/internal/controller/operation_log/operation_log_v1_get_output_log.go:113

			lines = append(lines, line)
		}
	}
	return lines, scanner.Err()
}

func reverseLines(lines []string) {
	for i, j := 0, len(lines)-1; i < j; i, j = i+1, j-1 {
		lines[i], lines[j] = lines[j], lines[i]
	}
}

func getLogFilesInRange(ctx context.Context, start, end string) ([]string, error) {
	logDir := public.AbsPath("../logs/core/out")
	layout := "2006-01-02"

	startDate, err := time.Parse(layout, start)
	if err != nil {
		return nil, fmt.Errorf("invalid start_date: %v", err)
	}
	endDate, err := time.Parse(layout, end)
	if err != nil {
		return nil, fmt.Errorf("invalid end_date: %v", err)
	}
	if endDate.Before(startDate) {
		return nil, fmt.Errorf("end_date must not be before start_date")
	}

	var files []string

	for d := startDate; !d.After(endDate); d = d.AddDate(0, 0, 1) {
		fname := filepath.Join(logDir, d.Format("2006-01-02")+".log")
		if _, err := os.Stat(fname); err == nil {
			files = append(files, fname)
		}
	}

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Format start_date strictly as YYYY-MM-DD before calling the API.
  2. Strip the time portion if you have an ISO datetime (take the first 10 characters).
  3. Make the parameter required/validated in the client before submission.

Example fix

// before
params.set('start_date', new Date().toISOString())  // 2026-09-05T12:00:00.000Z
// after
params.set('start_date', new Date().toISOString().slice(0, 10))  // 2026-09-05
Defensive patterns

Strategy: validation

Validate before calling

function isValidDate(s) {
  if (!/^\d{4}-\d{2}-\d{2}$/.test(s)) return false;
  const d = new Date(s + 'T00:00:00Z');
  return !isNaN(d.getTime()) && d.toISOString().slice(0, 10) === s;
}
if (!isValidDate(startDate)) throw new Error('start_date must be a valid YYYY-MM-DD date');

Try / catch

try {
  return await api.getOutputLog({startDate, endDate})
} catch (e) {
  if (/invalid start_date/.test(e.message)) {
    throw new UserInputError('start_date must match YYYY-MM-DD')
  }
  throw e
}

Prevention

When it happens

Trigger: Calling GetOutputLog with a start_date not matching YYYY-MM-DD: empty string, '09/01/2026', ISO datetime '2026-09-01T00:00:00Z', or unix timestamp.

Common situations: Frontend date pickers emitting locale-formatted dates; API clients sending full ISO timestamps; missing query parameter defaulting to empty string.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/47ea831657283a0c. Report an issue: GitHub.