grafana/k6 · error

script name not set, please specify K6_CLOUD_NAME or…

Error message

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

What it means

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.

Solutions

  1. Export K6_CLOUD_NAME before running: `export K6_CLOUD_NAME=my-test`.
  2. Or set the name in the script: `export const options = { cloud: { name: 'my-test' } }`.
  3. Or pass a real script file path instead of stdin so the base filename can be used.

Example fix

// before (k6 cloud - with stdin)
// (no name anywhere) -> error
// after
export const options = { cloud: { name: 'my-test' } };
Defensive patterns

Strategy: validation

Validate before calling

# when loading scripts from stdin, require an explicit name
if [ "${1:-}" = "-" ] || [ -z "$1" ]; then
  [ -z "${K6_CLOUD_NAME:-}" ] && { echo 'stdin scripts need K6_CLOUD_NAME or options.cloud.name'; exit 1; }
fi
k6 cloud "$@"

Prevention

When it happens

Trigger: `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.

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

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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

Appendix: 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 01ffac6f24)