{"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/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/output/cloud/output.go#L160-L196","documentation":"The cloud output must know when the test ends so it can close the cloud test run. lib.GetEndOffset walks the execution plan and reports whether a finite end exists; if no scenario yields a computable end time (testEnds=false), the output refuses to start with this error. This typically happens with open-ended executors such as externally-controlled scenarios without a bounded duration/endTime.","triggerScenarios":"k6 run -o cloud with a scenarios entry using executor 'externally-controlled' without a finite duration; an execution plan where the maximum end offset cannot be computed (no scenario defines duration/endTime/vUs-with-iterations bounds).","commonSituations":"Migrating a local test that ran fine without explicit durations to -o cloud; using externally-controlled scenarios intended for cloud execution but leaving timing unbounded; mixing stdin scripts with default options.","solutions":["Give every scenario an explicit duration or endTime (e.g., duration: '10m' on constant-vus/arrival-rate executors, or endTime in startTime+duration terms)","Replace open-ended executors with bounded ones (constant-arrival-rate with duration, per-vu-iterations with iterations) when pushing to the cloud","If the test is intentionally open-ended (manual control), drop the cloud output and run locally or drive it via k6 cloud UI execution"],"exampleFix":"// before\nexport const options = {\n  scenarios: { ctrl: { executor: 'externally-controlled', vus: 2, maxVUs: 10 } },\n};\n// after\nexport const options = {\n  scenarios: { ctrl: { executor: 'externally-controlled', vus: 2, maxVUs: 10, duration: '10m' } },\n};","handlingStrategy":"validation","validationCode":"// k6 script: assert every scenario has a bounded end before relying on cloud output\nfunction planIsBounded(scenarios) {\n  const bounded = ['constant-vus', 'ramping-vus', 'constant-arrival-rate', 'ramping-arrival-rate', 'shared-iterations', 'per-vu-iterations'];\n  return Object.values(scenarios).every((s) => bounded.includes(s.executor)\n    && (s.duration != null || s.iterations != null || (Array.isArray(s.stages) && s.stages.length > 0)));\n}\nif (!planIsBounded(options.scenarios || {})) {\n  throw new Error('All scenarios need a finite duration/iterations for -o cloud');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give externally-controlled scenarios an explicit duration or endTime when targeting the cloud","Smoke-test the exact options object with -o cloud before scheduling the real run","Treat 'no computable end' as a design smell for cloud runs — cloud tests must end"],"tags":["cloud","execution-plan","scenarios","configuration","k6"],"backgroundTag":"unbounded-execution-plan","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}