grafana/k6 · error

failed to initialize cloud secret source: %w

Error message

failed to initialize cloud secret source: %w

What it means

Error "failed to initialize cloud secret source: %w" thrown in grafana/k6.

Source

Thrown at internal/cmd/root.go:548

	if len(result) == 1 {
		for _, l := range result {
			result["default"] = l
		}
	}

	// Capture the cloud source instance if it was registered (via local-execution auto-injection
	// or the env-var path below), so createCloudTest can call SetConfig on it later.
	if cs, ok := result["cloud"].(*cloudsecrets.SecretSource); ok {
		gs.CloudSecretSource = cs
	}

	// When  K6_CLOUD_SECRETS_TOKEN + K6_CLOUD_SECRETS_ENDPOINT are injected, create and configure the cloud source
	// directly from env vars without a /v1/tests round-trip. Set it as the default source if none was chosen.
	if token := gs.Env["K6_CLOUD_SECRETS_TOKEN"]; token != "" {
		if gs.CloudSecretSource == nil {
			cloudSource, err := cloudsecrets.New(baseParams)
			if err != nil {
				return nil, fmt.Errorf("failed to initialize cloud secret source: %w", err)
			}
			result["cloud"] = cloudSource
			gs.CloudSecretSource = cloudSource
		}
		gs.CloudSecretSource.SetConfig(&cloudsecrets.Config{
			Token:        token,
			Endpoint:     gs.Env["K6_CLOUD_SECRETS_ENDPOINT"],
			ResponsePath: gs.Env["K6_CLOUD_SECRETS_RESPONSE_PATH"],
		})
		if _, ok := result["default"]; !ok {
			result["default"] = gs.CloudSecretSource
		}
	}

	return result, nil
}

// isCloudRunWithLocalExecution returns true when the command being executed is

View on GitHub (pinned to 93accf6570)

When it happens

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

Common situations: See trigger scenarios.


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