larksuite/cli · error

invalid timestamp %q: %w

Error message

invalid timestamp %q: %w

What it means

toRFC3339 converts --start/--end time input via common.ParseTime to Unix seconds, then to an RFC3339 string. If the intermediate value is not a parseable integer, it wraps the cause as 'invalid timestamp %q: %w'. This is an intermediate parse error wrapped into a typed ValidationError by parseTimeRange.

Source

Thrown at shortcuts/vc/vc_search.go:34

	"github.com/larksuite/cli/internal/output"
	"github.com/larksuite/cli/shortcuts/common"
)

const (
	defaultVCSearchPageSize = 15
	maxVCSearchPageSize     = 30
	maxVCSearchQueryLen     = 50
)

// toRFC3339 parses a time string via ParseTime (unix timestamp) and formats it as RFC3339.
func toRFC3339(input string, hint ...string) (string, error) {
	ts, err := common.ParseTime(input, hint...)
	if err != nil {
		return "", err
	}
	sec, err := strconv.ParseInt(ts, 10, 64)
	if err != nil {
		return "", fmt.Errorf("invalid timestamp %q: %w", ts, err) //nolint:forbidigo // intermediate parse error; callers wrap it into a typed ValidationError
	}
	return time.Unix(sec, 0).Format(time.RFC3339), nil
}

// parseTimeRange validates --start/--end and returns RFC3339 formatted strings.
func parseTimeRange(runtime *common.RuntimeContext) (string, string, error) {
	start := strings.TrimSpace(runtime.Str("start"))
	end := strings.TrimSpace(runtime.Str("end"))
	if start == "" && end == "" {
		return "", "", nil
	}
	var startTime, endTime string
	if start != "" {
		parsed, err := toRFC3339(start)
		if err != nil {
			return "", "", errs.NewValidationError(errs.SubtypeInvalidArgument, "--start: %v", err).WithParam("--start")
		}
		startTime = parsed

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Provide RFC3339 timestamps ('2026-09-04T00:00:00Z') or a common 'YYYY-MM-DD HH:MM' form.
  2. Inspect the wrapped cause to see the actual strconv failure.
  3. If passing Unix seconds directly, use a plain base-10 integer string.
  4. Confirm accepted formats in the command's --help/schema output.

Example fix

// before
--start "yesterday 9pm"
// after
--start "2026-09-03T21:00:00+08:00"
Defensive patterns

Strategy: validation

Validate before calling

ts, err := common.ParseTime(input)
if err != nil { return err }
if _, err := strconv.ParseInt(ts, 10, 64); err != nil {
	return fmt.Errorf("--start/--end must resolve to Unix seconds, got %q", ts)
}

Type guard

func isUnixSecondsString(s string) bool {
	_, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64)
	return err == nil
}

Try / catch

if err := run(); err != nil {
	var ve *errs.ValidationError
	if errors.As(err, &ve) { return fmt.Errorf("bad time range: %w (use RFC3339)", ve) }
	return err
}

Prevention

When it happens

Trigger: Calling VC search with --start/--end values that ParseTime accepts but whose output is not an integer string (anomalous pass-through), since ParseTime's own failures return unwrapped before this point.

Common situations: Unusual or locale-specific date strings that a pass-through parser accepted, or programmatic callers feeding pre-formatted timestamps in the wrong form.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/0f90907603338c4b. Report an issue: GitHub.