{"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/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/dashboard/options.go#L181-L217","documentation":"The web dashboard output parses its `period` setting with Go's time.ParseDuration (options.go:81 and :139); on parse failure it discards the underlying detail and returns the generic errInvalidDuration. Period controls how often metric points are sampled into the report.","triggerScenarios":"Setting K6_WEB_DASHBOARD_PERIOD or `--out web-dashboard=period=...` to a bare number ('10', '500') or unit-less/misspelled value ('10 seconds', '10sec') — values must carry a Go duration unit such as '10s', '1m', '1m30s'.","commonSituations":"Assuming milliseconds or seconds are the default unit; copying duration syntax from other tools; CI env vars written without units.","solutions":["Use Go duration syntax with an explicit unit: K6_WEB_DASHBOARD_PERIOD=10s or --out web-dashboard=period=30s","Supported units: ns, us (µs), ms, s, m, h; compound values like 1m30s work","Leave period unset to keep the 10s default"],"exampleFix":"# before\nK6_WEB_DASHBOARD_PERIOD=10 k6 run --out web-dashboard script.js\n\n# after\nK6_WEB_DASHBOARD_PERIOD=10s k6 run --out web-dashboard script.js","handlingStrategy":"validation","validationCode":"# Reject unit-less dashboard periods before launching\nperiod=\"${K6_WEB_DASHBOARD_PERIOD:-10s}\"\ncase \"$period\" in\n  *[0-9](ns|us|ms|s|m|h)) ;;\n  *) echo \"K6_WEB_DASHBOARD_PERIOD must use Go duration units (e.g. 10s, 1m)\" >&2; exit 1;;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write dashboard periods with an explicit Go unit (10s, 1m, 500ms)","Lift dashboard env vars into one documented place so typos surface in review","Remember k6 duration strings are Go durations, never bare milliseconds"],"tags":["dashboard","configuration","duration","output"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}