grafana/k6 · error

parse environment variables options failed: %w

Error message

parse environment variables options failed: %w

What it means

One or more K6_OTEL_* environment variables could not be processed into the OpenTelemetry output config. GetConsolidatedConfig wraps the envconfig/parse failure; typically a non-boolean for a bool flag or invalid duration/null-type value.

Source

Thrown at internal/output/opentelemetry/config.go:95

}

// GetConsolidatedConfig combines the options' values from the different sources
// and returns the merged options. The Order of precedence used is documented
// in the k6 Documentation https://grafana.com/docs/k6/latest/using-k6/k6-options/how-to/#order-of-precedence.
func GetConsolidatedConfig(jsonRawConf json.RawMessage, env map[string]string) (Config, error) {
	cfg := newDefaultConfig()
	if jsonRawConf != nil {
		jsonConf, err := parseJSON(jsonRawConf)
		if err != nil {
			return cfg, fmt.Errorf("parse JSON options failed: %w", err)
		}
		cfg = cfg.Apply(jsonConf)
	}

	if len(env) > 0 {
		envConf, err := parseEnvs(env)
		if err != nil {
			return cfg, fmt.Errorf("parse environment variables options failed: %w", err)
		}
		cfg = cfg.Apply(envConf)
	}

	if err := cfg.Validate(); err != nil {
		// TODO: check why k6's still exiting with 255
		return cfg, errext.WithExitCodeIfNone(
			fmt.Errorf("error validating OpenTelemetry output config: %w", err),
			exitcodes.InvalidConfig,
		)
	}

	return cfg, nil
}

// newDefaultConfig creates a new default config with default values
func newDefaultConfig() Config {
	return Config{

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Check the wrapped error for the offending variable
  2. Use valid values, e.g. K6_OTEL_GRPC_EXPORTER_INSECURE=true and valid durations for interval settings
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/output/opentelemetry/config.go:95 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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