{"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/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/outputs_cloud.go#L305-L341","documentation":"resolveCloudTestName derives the cloud test name from options.cloud.name or K6_CLOUD_NAME; when neither is set it falls back to the script file basename. If the script is loaded from stdin (empty script path) there is nothing to derive, so it errors: cloud runs require a non-empty name.","triggerScenarios":"`cat script.js | k6 run --out cloud -` or `k6 cloud -` with neither K6_CLOUD_NAME set nor `options.cloud.name` exported in the script.","commonSituations":"CI pipelines piping generated scripts into k6; running archives built without a name; scripts migrated from the legacy cloud output where the name was optional.","solutions":["Export K6_CLOUD_NAME='my-test' before the run","Or add `cloud: { name: 'my-test' }` to the script's exported options","Or run from a script file path so filepath.Base(scriptPath) can be used"],"exampleFix":"// before\ncat script.js | k6 run --out cloud -\n\n// after\nK6_CLOUD_NAME=my-test cat script.js | k6 run --out cloud -\n// or in the script:\nexport const options = { cloud: { name: 'my-test' } };","handlingStrategy":"validation","validationCode":"# When the script comes from stdin, force a cloud name\nif [ \"${K6_CLOUD_NAME:-}\" = \"\" ] && [ \"${1:-}\" = \"-\" ]; then\n  export K6_CLOUD_NAME=\"${CI_JOB_NAME:-local-k6-test}\"\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set K6_CLOUD_NAME in every CI job template that pipes scripts via stdin","Prefer `cloud: { name: ... }` in exported options so the name travels with the script","Run named script files when possible so the basename fallback exists"],"tags":["cloud","configuration","stdin","naming"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}