{"record":{"id":"a752ecf74baa02b2","repo":"grafana/k6","slug":"script-name-not-set-please-specify-k6-cloud-name","errorCode":null,"errorMessage":"script name not set, please specify K6_CLOUD_NAME or options.cloud.name","messagePattern":"script name not set, please specify K6_CLOUD_NAME or options\\.cloud\\.name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/outputs_cloud.go","lineNumber":323,"sourceCode":"\treturn nil\n}\n\nfunc cloudConfToRawMessage(conf cloudapi.Config) (json.RawMessage, error) {\n\tvar buff bytes.Buffer\n\tenc := json.NewEncoder(&buff)\n\tif err := enc.Encode(conf); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buff.Bytes(), nil\n}\n\n// resolveCloudTestName returns the test name from the config, or derives it from\n// the script path when the config name is unset. A name of \"-\" is replaced\n// with the default test name.\nfunc resolveCloudTestName(name null.String, scriptPath string) (null.String, error) {\n\tif !name.Valid || name.String == \"\" {\n\t\tif scriptPath == \"\" {\n\t\t\treturn name, errors.New(\"script name not set, please specify K6_CLOUD_NAME or options.cloud.name\")\n\t\t}\n\t\tname = null.StringFrom(filepath.Base(scriptPath))\n\t}\n\tif name.String == \"-\" {\n\t\tname = null.StringFrom(defaultTestName)\n\t}\n\treturn name, nil\n}\n\n// buildConfigFromRuntimeConfig maps provisioning RuntimeConfig fields\n// to cloudapi.Config fields.\n//\n// If the backend returns an unparseable duration string, a warning is\n// logged and the cloudapi.Config default is kept. Graceful degradation\n// is preferable to blocking the user for a backend-side bug.\nfunc buildConfigFromRuntimeConfig(\n\tlogger logrus.FieldLogger, rc provisioning.RuntimeConfig,\n) cloudapi.Config {","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/outputs_cloud.go#L305-L341","documentation":"resolveCloudTestName (internal/cmd/outputs_cloud.go:323) derives the cloud test name: if options.cloud.name / K6_CLOUD_NAME is unset it falls back to the script file's base name. When the config name is unset AND there is no script path (script read from stdin), no name can be derived and the error is returned. A name of '-' is replaced by the default test name.","triggerScenarios":"`k6 cloud -` or otherwise loading the script from stdin without K6_CLOUD_NAME set and without options.cloud.name in the script; archiving/running configurations where test.source.URL is empty.","commonSituations":"Piping scripts in CI (`cat script.js | k6 cloud -`); generated scripts where the options block with cloud.name was stripped; automation that deliberately uses '-' as a placeholder but the config value is empty rather than literally '-'.","solutions":["Export K6_CLOUD_NAME before running: `export K6_CLOUD_NAME=my-test`.","Or set the name in the script: `export const options = { cloud: { name: 'my-test' } }`.","Or pass a real script file path instead of stdin so the base filename can be used."],"exampleFix":"// before (k6 cloud - with stdin)\n// (no name anywhere) -> error\n// after\nexport const options = { cloud: { name: 'my-test' } };","handlingStrategy":"validation","validationCode":"# when loading scripts from stdin, require an explicit name\nif [ \"${1:-}\" = \"-\" ] || [ -z \"$1\" ]; then\n  [ -z \"${K6_CLOUD_NAME:-}\" ] && { echo 'stdin scripts need K6_CLOUD_NAME or options.cloud.name'; exit 1; }\nfi\nk6 cloud \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set options.cloud.name in every cloud-run script template so name derivation never depends on the file path.","In CI, export K6_CLOUD_NAME derived from the pipeline name for stable dashboards."],"tags":["cloud","naming","configuration","stdin"],"backgroundTag":"missing-required-config","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"}