grafana/k6 · error

could not create the cloud test run

Error message

could not create the cloud test run: %w

What it means

In cloud run with --local-execution, createCloudTest failed to register the test run with the Grafana Cloud k6 API. The wrapped error is typically an auth failure (bad token), an unreachable cloud host, or a rejected test definition.

Solutions

  1. Verify K6_CLOUD_TOKEN / the cloud API token is valid and has the right permissions
  2. Check K6_CLOUD_HOST connectivity and any proxy settings
  3. Inspect the wrapped error for the API's rejection reason
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/cmd/cloud_run.go:160 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at internal/cmd/cloud_run.go:166

		)
	}

	return applyCloudEnvOverrides(c.gs, cmd, &c.showCloudLogs, &c.exitOnRunning)
}

func (c *cmdCloudRun) run(cmd *cobra.Command, args []string) error {
	if c.localExecution {
		c.runCmd.loadConfiguredTest = func(*cobra.Command, []string) (*loadedAndConfiguredTest, execution.Controller, error) {
			test, err := loadAndConfigureLocalTest(c.runCmd.gs, cmd, args, getCloudRunLocalExecutionConfig)
			if err != nil {
				return nil, nil, fmt.Errorf("could not load and configure the test: %w", err)
			}

			if err := createCloudTest(c.runCmd.gs, test); err != nil {
				if errors.Is(err, errCloudAuth) {
					return nil, nil, err
				}
				return nil, nil, fmt.Errorf("could not create the cloud test run: %w", err)
			}

			return test, local.NewController(), nil
		}
		return c.runCmd.run(cmd, args)
	}

	// When running the `k6 cloud run` command explicitly disable the usage report.
	c.noUsageReport = true

	return runCloudTest(c.gs, cmd, args, cloudTestRunOptions{
		showCloudLogs: c.showCloudLogs,
		exitOnRunning: c.exitOnRunning,
	})
}

func (c *cmdCloudRun) flagSet() *pflag.FlagSet {
	flags := pflag.NewFlagSet("", pflag.ContinueOnError)

View on GitHub (pinned to 94169daab2)