grafana/k6 · error

the --no-cloud-logs flag can only be used in conjunction wit

Error message

the --no-cloud-logs flag can only be used in conjunction with the --local-execution flag

What it means

The `k6 cloud run` preRun hook rejects --no-cloud-logs without --local-execution. Disabling log push to the cloud only applies when execution is local (cloud-executed tests inherently log in the cloud), so the combination is contradictory. The error exits with code InvalidConfig (104).

Source

Thrown at internal/cmd/cloud_run.go:140

	}

	if c.linger {
		return errext.WithExitCodeIfNone(
			fmt.Errorf("the --linger flag can only be used in conjunction with the --local-execution flag"),
			exitcodes.InvalidConfig,
		)
	}

	if c.noCloudSecrets {
		return errext.WithExitCodeIfNone(
			fmt.Errorf("the --no-cloud-secrets flag can only be used in conjunction with the --local-execution flag"),
			exitcodes.InvalidConfig,
		)
	}

	if c.noCloudLogs {
		return errext.WithExitCodeIfNone(
			fmt.Errorf("the --no-cloud-logs flag can only be used in conjunction with the --local-execution flag"),
			exitcodes.InvalidConfig,
		)
	}

	return c.deprecatedCloudCmd.preRun(cmd, args)
}

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

View on GitHub (pinned to 93accf6570)

Solutions

  1. Add --local-execution to keep logs purely local
  2. Or drop --no-cloud-logs for cloud-executed runs
  3. Gate the flag in CI scripts on the chosen execution mode

Example fix

# before
k6 cloud run --no-cloud-logs script.js
# after
k6 cloud run --local-execution --no-cloud-logs script.js
Defensive patterns

Strategy: validation

Validate before calling

if slices.Contains(args, "--no-cloud-logs") && !slices.Contains(args, "--local-execution") {
    log.Fatal("--no-cloud-logs requires --local-execution")
}

Prevention

When it happens

Trigger: Invoking `k6 cloud run --no-cloud-logs ...` without --local-execution present on the command line.

Common situations: Cost/privacy-driven flag sets reused across commands; wrappers that always append --no-cloud-logs; migrating from `k6 run` with cloud output to `k6 cloud run`.

Related errors


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