grafana/k6 · error
unable to use type %T as a duration value
Error message
unable to use type %T as a duration value
What it means
Raised by getInt64 (a helper behind GetDurationValue) when the duration option's value is of a Go type the helper does not handle — typically a JavaScript value that could not be narrowed to a numeric or string type. %P-style placeholder reports the actual type.
Source
Thrown at lib/types/types.go:189
case int32:
return int64(n), nil
case int64:
return n, nil
case uint:
return int64(n), nil //nolint:gosec
case uint8:
return int64(n), nil
case uint16:
return int64(n), nil
case uint32:
return int64(n), nil
case uint64:
if n > math.MaxInt64 {
return 0, fmt.Errorf("%d is too big", n)
}
return int64(n), nil
default:
return 0, fmt.Errorf("unable to use type %T as a duration value", v)
}
}
// GetDurationValue is a helper function that can convert a lot of different
// types to time.Duration.
//
// TODO: move to a separate package and check for integer overflows?
func GetDurationValue(v any) (time.Duration, error) {
switch d := v.(type) {
case time.Duration:
return d, nil
case string:
return ParseExtendedDuration(d)
case float32:
return time.Duration(float64(d) * float64(time.Millisecond)), nil
case float64:
return time.Duration(d * float64(time.Millisecond)), nil
default:View on GitHub (pinned to 01ffac6f24)
Solutions
- Pass durations as strings ("30s") or numbers
- Avoid passing objects, arrays, booleans or null as duration values
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/types/types.go:189 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/b199eacfa9e112e3.
Report an issue: GitHub.