{"record":{"id":"03133ee0b288c832","repo":"grafana/k6","slug":"s-is-not-a-valid-duration-value","errorCode":null,"errorMessage":"'%s' is not a valid duration value","messagePattern":"'(.+?)' is not a valid duration value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/types/types.go","lineNumber":86,"sourceCode":"\n// UnmarshalJSON converts JSON data to Duration\nfunc (d *Duration) UnmarshalJSON(data []byte) error {\n\tif len(data) > 0 && data[0] == '\"' {\n\t\tvar str string\n\t\tif err := json.Unmarshal(data, &str); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tv, err := ParseExtendedDuration(str)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t*d = Duration(v)\n\t} else if t, errp := strconv.ParseFloat(string(data), 64); errp == nil {\n\t\t*d = Duration(t * float64(time.Millisecond))\n\t} else {\n\t\treturn fmt.Errorf(\"'%s' is not a valid duration value\", string(data))\n\t}\n\n\treturn nil\n}\n\n// MarshalJSON returns the JSON representation of d\nfunc (d Duration) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(d.String())\n}\n\n// NullDuration is a nullable Duration, in the same vein as the nullable types provided by\n// package gopkg.in/guregu/null.v3.\ntype NullDuration struct {\n\tDuration\n\tValid bool\n}\n\n// NewNullDuration is a simple helper constructor function","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/types/types.go#L68-L104","documentation":"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.","triggerScenarios":"Thrown at lib/types/types.go:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide durations as strings like \"30s\", \"1m\", \"2d\" or as numbers meaning milliseconds","Check for typos such as missing units or stray characters"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}