{"record":{"id":"d2a7fa7d1d9b16c7","repo":"grafana/k6","slug":"invalid-duration","errorCode":null,"errorMessage":"invalid duration","messagePattern":"invalid duration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/dashboard/options.go","lineNumber":199,"sourceCode":"}\n\n// period adjusts period, limit points per test run to 'points'.\nfunc (opts *options) period(duration time.Duration) time.Duration {\n\tif duration == 0 {\n\t\treturn opts.Period\n\t}\n\n\toptimal := float64(duration) / float64(points)\n\n\treturn time.Duration(math.Ceil(optimal/float64(opts.Period))) * opts.Period\n}\n\n/*\napprox. 1MB max report size, 8 hours test run with 10sec event period.\n*/\nconst points = 2880\n\nvar errInvalidDuration = errors.New(\"invalid duration\")\n\nconst (\n\tenvPrefix = \"K6_WEB_DASHBOARD_\"\n\n\tparamPort = \"port\"\n\tenvPort   = envPrefix + \"PORT\"\n\n\tparamHost = \"host\"\n\tenvHost   = envPrefix + \"HOST\"\n\n\tparamPeriod = \"period\"\n\tenvPeriod   = envPrefix + \"PERIOD\"\n\n\tparamOpen = \"open\"\n\tenvOpen   = envPrefix + \"OPEN\"\n\n\tparamReport = \"report\"\n\tenvReport   = envPrefix + \"REPORT\"","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/dashboard/options.go#L181-L217","documentation":"Dashboard options parsing (internal/dashboard/options.go:199 defines errInvalidDuration; used at lines 83 and 141) converts the sampling period to a Go time.Duration. If K6_WEB_DASHBOARD_PERIOD or the `period` query param of `--out web-dashboard=period=...` is not a valid Go duration string, errInvalidDuration is returned.","triggerScenarios":"Setting K6_WEB_DASHBOARD_PERIOD=10 (no unit), =10seconds (wrong unit word), or =1sec instead of Go syntax like 10s, 1m, 500ms; the same value passed as `--out web-dashboard=period=10s`.","commonSituations":"Users assuming seconds-by-default or JS-style durations ('10sec'); porting configs between tools with different duration grammars.","solutions":["Use Go duration syntax: `K6_WEB_DASHBOARD_PERIOD=10s`, or `1m`, `500ms`.","Double-check the `period=` value inside the `--out web-dashboard=...` query string."],"exampleFix":"# before\nK6_WEB_DASHBOARD_PERIOD=10 k6 run --web-dashboard script.js\n# after\nK6_WEB_DASHBOARD_PERIOD=10s k6 run --web-dashboard script.js","handlingStrategy":"validation","validationCode":"# validate Go duration syntax before launching k6\nif [ -n \"${K6_WEB_DASHBOARD_PERIOD:-}\" ] && ! echo \"$K6_WEB_DASHBOARD_PERIOD\" | grep -qE '^[0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h)$'; then\n  echo \"K6_WEB_DASHBOARD_PERIOD must look like 10s, 1m, 500ms\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember k6 durations use Go syntax (10s) — never bare numbers or JS-style 10sec.","Keep dashboard settings in one env block with a comment showing valid examples."],"tags":["dashboard","duration","configuration","web-dashboard","env-vars"],"backgroundTag":"invalid-duration-format","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}