grafana/k6 · error

the --no-cloud-secrets flag can only be used in conjunction

Error message

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

What it means

The `k6 cloud run` preRun hook rejects --no-cloud-secrets without --local-execution. Automatic cloud secret-source configuration is a local-execution feature (the cloud runner resolves secrets server-side), so the flag has no effect for cloud-executed tests and is rejected up front. The error exits with code InvalidConfig (104).

Source

Thrown at internal/cmd/cloud_run.go:133

			return errext.WithExitCodeIfNone(
				fmt.Errorf("the --local-execution flag is not compatible with the --show-logs flag"),
				exitcodes.InvalidConfig,
			)
		}

		return nil
	}

	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)

View on GitHub (pinned to 93accf6570)

Solutions

  1. Add --local-execution if you intend to run locally without the cloud secret source
  2. Or remove --no-cloud-secrets for cloud-executed tests
  3. Split shared flag templates by execution mode

Example fix

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

Strategy: validation

Validate before calling

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

Prevention

When it happens

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

Common situations: Teams standardizing a flag set across local and cloud runs; copy-pasting a security-hardened local invocation into the cloud path.

Related errors


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