grafana/k6 · error
'%s' is not a valid duration value
Error message
'%s' is not a valid duration value
What it means
Raised by Duration.UnmarshalJSON when the JSON value for a duration-typed option is neither a quoted string parseable by ParseExtendedDuration nor a bare number (interpreted as milliseconds). It is the fallback error for unparseable duration input.
Source
Thrown at lib/types/types.go:86
// UnmarshalJSON converts JSON data to Duration
func (d *Duration) UnmarshalJSON(data []byte) error {
if len(data) > 0 && data[0] == '"' {
var str string
if err := json.Unmarshal(data, &str); err != nil {
return err
}
v, err := ParseExtendedDuration(str)
if err != nil {
return err
}
*d = Duration(v)
} else if t, errp := strconv.ParseFloat(string(data), 64); errp == nil {
*d = Duration(t * float64(time.Millisecond))
} else {
return fmt.Errorf("'%s' is not a valid duration value", string(data))
}
return nil
}
// MarshalJSON returns the JSON representation of d
func (d Duration) MarshalJSON() ([]byte, error) {
return json.Marshal(d.String())
}
// NullDuration is a nullable Duration, in the same vein as the nullable types provided by
// package gopkg.in/guregu/null.v3.
type NullDuration struct {
Duration
Valid bool
}
// NewNullDuration is a simple helper constructor functionView on GitHub (pinned to 01ffac6f24)
Solutions
- Provide durations as strings like "30s", "1m", "2d" or as numbers meaning milliseconds
- Check for typos such as missing units or stray characters
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/types/types.go:86 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/03133ee0b288c832.
Report an issue: GitHub.