grafana/k6 · error

initializing feature flags

Error message

initializing feature flags: %w

What it means

Wrapped error from resolveFeatureFlags: features.Init failed while merging feature flag sources (CLI --features, config file, and environment). Typically caused by an unknown feature flag name or a value not accepted by the flag's lifecycle rules.

Solutions

  1. Check the wrapped error for the offending flag name or value
  2. Use 'k6 features' to list valid flag names and their lifecycle status
  3. Remove unsupported overrides from --features, config, or K6_FEATURES env
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/cmd/features.go:119 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/c9d0d30d6b149058. Report an issue: GitHub.

Appendix: source

Thrown at internal/cmd/features.go:119

	fileConf, err := readDiskConfig(gs)
	if err != nil {
		return errext.WithExitCodeIfNone(
			fmt.Errorf("failed to load the configuration file from the local file system: %w", err),
			exitcodes.InvalidConfig,
		)
	}
	jsonSurface := features.Source{Values: fileConf.Features, Supplied: fileConf.Features != nil}

	envSurface := maps.Clone(gs.Env)
	if envSurface == nil {
		envSurface = make(map[string]string)
	}
	maps.Copy(envSurface, piState.RuntimeOptions.Env)

	flags, err := features.Init(gs.Logger, cli, jsonSurface, envSurface)
	if err != nil {
		return fmt.Errorf("initializing feature flags: %w", err)
	}
	piState.FeatureFlags = flags

	for _, name := range flags.Activated() {
		if err := gs.Usage.Strings("features", name); err != nil {
			gs.Logger.WithError(err).Debugf("reporting feature usage for %q", name)
		}
	}

	propagateFeatureEnv(piState.RuntimeOptions.Env, flags.Activated())
	return nil
}

func warnOnScriptOptionsFeatures(logger logrus.FieldLogger, opts lib.Options) {
	if len(opts.Features) == 0 {
		return
	}
	logger.WithField("source", "options").

View on GitHub (pinned to 01ffac6f24)