grafana/k6 · error

no secret source for type

Error message

no secret source for type %q for configuration %q

What it means

The type before '=' in a --secret-source entry must match a registered secret source extension. Stock k6 registers only 'file', 'mock', and 'url' ('cloud' is special-cased and rejected separately with a dedicated message). An unknown type aborts startup, naming the bad type and echoing the full offending entry so trailing garbage is visible.

Solutions

  1. Use a registered type: file, mock, or url — e.g. --secret-source=file=secrets.txt
  2. Check for trailing commas or stray characters: the error echoes the exact entry; 'file,' is not 'file'
  3. If you need vault/aws-sm/etc., build k6 with the xk6 extension providing it, or export the secrets to a file and use file=
  4. Verify available sources with `k6 run --secret-source=nonexistent x.js` — the error lists what you asked for; consult docs for your build's registered sources

Example fix

# before
k6 run --secret-source=vault=myvault script.js

# after
k6 run --secret-source=file=secrets.txt script.js
Defensive patterns

Strategy: validation

Validate before calling

# check each secret source type against the sources this binary registers
known_sources="file mock url"   # add your xk6 extension's sources here
for entry in "$@"; do
  type="${entry%%=*}"
  found=0
  for k in $known_sources; do [ "$type" = "$k" ] && found=1; done
  [ "$found" = 1 ] || { echo "unknown secret source type: $type" >&2; exit 1; }
done

Prevention

When it happens

Trigger: --secret-source=vault=myvault (no such source in this binary); --secret-source=file, (trailing comma makes the parsed type 'file,'); using a type provided only by an xk6 extension build in a stock k6 binary; simple typos like fille=...

Common situations: Assuming k6 has built-in Vault/AWS Secrets Manager support; trailing commas from comma-separated config lists; teams sharing commands between a custom xk6 build and vanilla k6.

Related errors


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

Appendix: source

Thrown at internal/cmd/root.go:514

		Usage:       gs.Usage,
	}

	result := make(map[string]secretsource.Source)
	for _, line := range gs.Flags.SecretSource {
		t, config, ok := strings.Cut(line, "=")
		if !ok {
			if strings.TrimSpace(line) == "" {
				return nil, fmt.Errorf("couldn't parse secret source configuration %q", line)
			}
			// Allow any non-empty source type without explicit config — it will use
			// environment variables and built-in defaults.
			t = line
			config = ""
		}
		secretSources := ext.Get(ext.SecretSourceExtension)
		found, ok := secretSources[t]
		if !ok {
			return nil, fmt.Errorf("no secret source for type %q for configuration %q", t, line)
		}
		c := found.Module.(secretsource.Constructor) //nolint:forcetypeassert
		params := baseParams
		name, isDefault, config := extractNameAndDefault(config)
		if name == "" {
			// Default the name to the source type to avoid an empty-string key.
			name = t
		}
		params.ConfigArgument = config

		secretSource, err := c(params)
		if err != nil {
			return nil, err
		}
		_, alreadRegistered := result[name]
		if alreadRegistered {
			return nil, fmt.Errorf("secret source for name %q already registered before configuration %q", t, line)
		}

View on GitHub (pinned to 8d06114777)