grafana/k6 · error

script name not set, please specify K6_CLOUD_NAME or options

Error message

script name not set, please specify K6_CLOUD_NAME or options.cloud.name

What it means

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.

Source

Thrown at internal/cmd/outputs_cloud.go:323

	return nil
}

func cloudConfToRawMessage(conf cloudapi.Config) (json.RawMessage, error) {
	var buff bytes.Buffer
	enc := json.NewEncoder(&buff)
	if err := enc.Encode(conf); err != nil {
		return nil, err
	}
	return buff.Bytes(), nil
}

// resolveCloudTestName returns the test name from the config, or derives it from
// the script path when the config name is unset. A name of "-" is replaced
// with the default test name.
func resolveCloudTestName(name null.String, scriptPath string) (null.String, error) {
	if !name.Valid || name.String == "" {
		if scriptPath == "" {
			return name, errors.New("script name not set, please specify K6_CLOUD_NAME or options.cloud.name")
		}
		name = null.StringFrom(filepath.Base(scriptPath))
	}
	if name.String == "-" {
		name = null.StringFrom(defaultTestName)
	}
	return name, nil
}

// buildConfigFromRuntimeConfig maps provisioning RuntimeConfig fields
// to cloudapi.Config fields.
//
// If the backend returns an unparseable duration string, a warning is
// logged and the cloudapi.Config default is kept. Graceful degradation
// is preferable to blocking the user for a backend-side bug.
func buildConfigFromRuntimeConfig(
	logger logrus.FieldLogger, rc provisioning.RuntimeConfig,
) cloudapi.Config {

View on GitHub (pinned to 93accf6570)

Solutions

  1. Export K6_CLOUD_NAME='my-test' before the run
  2. Or add `cloud: { name: 'my-test' }` to the script's exported options
  3. Or run from a script file path so filepath.Base(scriptPath) can be used

Example fix

// before
cat script.js | k6 run --out cloud -

// after
K6_CLOUD_NAME=my-test cat script.js | k6 run --out cloud -
// or in the script:
export const options = { cloud: { name: 'my-test' } };
Defensive patterns

Strategy: validation

Validate before calling

# When the script comes from stdin, force a cloud name
if [ "${K6_CLOUD_NAME:-}" = "" ] && [ "${1:-}" = "-" ]; then
  export K6_CLOUD_NAME="${CI_JOB_NAME:-local-k6-test}"
fi

Prevention

When it happens

Trigger: `cat script.js | k6 run --out cloud -` or `k6 cloud -` with neither K6_CLOUD_NAME set nor `options.cloud.name` exported in the script.

Common situations: 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.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/a752ecf74baa02b2. Report an issue: GitHub.