{"record":{"id":"05f3ab00af4e25ac","repo":"grafana/k6","slug":"tests-with-unspecified-duration-are-not-allowed-wh-05f3ab","errorCode":null,"errorMessage":"tests with unspecified duration are not allowed when outputting data to k6 cloud","messagePattern":"tests with unspecified duration are not allowed when outputting data to k6 cloud","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/cloud/output.go","lineNumber":178,"sourceCode":"\n\tlogger := params.Logger.WithFields(logrus.Fields{\"output\": \"cloud\"})\n\n\tif !conf.Name.Valid || conf.Name.String == \"\" {\n\t\tscriptPath := params.ScriptPath.String()\n\t\tif scriptPath == \"\" {\n\t\t\t// Script from stdin without a name, likely from stdin\n\t\t\treturn nil, errors.New(\"script name not set, please specify K6_CLOUD_NAME or options.cloud.name\")\n\t\t}\n\n\t\tconf.Name = null.StringFrom(filepath.Base(scriptPath))\n\t}\n\tif conf.Name.String == \"-\" {\n\t\tconf.Name = null.StringFrom(defaultTestName)\n\t}\n\n\tduration, testEnds := lib.GetEndOffset(params.ExecutionPlan)\n\tif !testEnds {\n\t\treturn nil, errors.New(\"tests with unspecified duration are not allowed when outputting data to k6 cloud\")\n\t}\n\n\tif conf.MetricPushConcurrency.Int64 < 1 {\n\t\treturn nil, fmt.Errorf(\"metrics push concurrency must be a positive number but is %d\",\n\t\t\tconf.MetricPushConcurrency.Int64)\n\t}\n\n\tif conf.MaxTimeSeriesInBatch.Int64 < 1 {\n\t\treturn nil, fmt.Errorf(\"max allowed number of time series in a single batch must be a positive number but is %d\",\n\t\t\tconf.MaxTimeSeriesInBatch.Int64)\n\t}\n\n\tapiClient := cloudapi.NewClient(\n\t\tlogger, conf.Token.String, conf.Host.String, build.Version, conf.Timeout.TimeDuration())\n\n\treturn &Output{\n\t\tconfig:        conf,\n\t\tclient:        apiClient,","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/output/cloud/output.go#L160-L196","documentation":"Thrown by the cloud output's constructor when the calculated execution plan has no determinable end time. Before opening a cloud output, k6 calls lib.GetEndOffset(params.ExecutionPlan); if it reports that the test never ends (testEnds == false), the cloud output refuses to start because the k6 Cloud service requires a bounded test duration to provision and finalize a test run.","triggerScenarios":"Any configuration that activates the cloud output (k6 cloud run --local-execution, -o cloud, or options.cloud) combined with an open-ended execution plan: a script using only 'vus'/'iterations' style options without a duration (e.g. exported handleSummary-style scripts run with vus:1, iterations:0), a scenario with an executor that has no endTime/duration (e.g. manual or shared-iterations without iteration limits, or a constant-vus scenario with duration: 0 / unset), or a plan whose max end offset cannot be computed.","commonSituations":"Migrating an old script that relied on externally stopped runs (k6 pause/scale workflows) to cloud output; setting options.vus and options.iterations but forgetting options.duration when also enabling -o cloud; CI scripts that assume indefinite runs stopped by timeout; using execution: { scenarios: { s: { executor: 'constant-vus', vus: 1 } } } with no duration field.","solutions":["Add a bounded duration to the script: export const options = { vus: 10, duration: '30s' } or give every scenario an explicit duration/endTime","If using execution scenarios, ensure each executor produces a known end (e.g. constant-vus with duration, per-vu-iterations with iterations set)","If the test is intentionally open-ended, drop the cloud output and use a local output (-o json, -o csv, -o prometheus-rw) instead","Check options merging: a CLI flag like --duration 0 or --vus without --duration may have overridden the script's duration"],"exampleFix":"// before\nexport const options = { vus: 10, iterations: 1000 }; // no duration, never 'ends' for cloud\n\n// after\nexport const options = { vus: 10, duration: '2m' };","handlingStrategy":"validation","validationCode":"# Before enabling the cloud output, confirm the plan has a finite end:\nk6 inspect --execution 'script.js' | jq '[.scenarios[] | has(\"endTime\") or has(\"duration\")] | all'\n# Or in Go, before constructing the output:\n// _, testEnds := lib.GetEndOffset(executionPlan); if !testEnds { /* refuse */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always export a duration (or bounded executors) in options when cloud output is enabled","Add a CI preflight step: k6 inspect script.js and fail if no scenario reports an end time","Treat 'vus without duration' as a lint error in script review"],"tags":["k6","cloud","execution-plan","duration","config"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}