grafana/k6 · error

executor %s: function '%s' not found in exports

Error message

executor %s: function '%s' not found in exports

What it means

Produced by validateScenarioConfig during options validation: every scenario/executor config has an `exec` field naming the exported function it should call, and that name is checked against the script's actual exports via the isExecutable predicate. If the scenario's exec value is not among the exported functions (the default-export object's keys), k6 refuses to run because the executor would have nothing to call.

Source

Thrown at internal/cmd/config.go:359

}

func consolidateErrorMessage(errList []error, title string) error {
	if len(errList) == 0 {
		return nil
	}

	errMsgParts := []string{title}
	for _, err := range errList {
		errMsgParts = append(errMsgParts, fmt.Sprintf("\t- %s", err.Error()))
	}

	return errors.New(strings.Join(errMsgParts, "\n"))
}

func validateScenarioConfig(conf lib.ExecutorConfig, isExecutable func(string) bool) error {
	execFn := conf.GetExec()
	if !isExecutable(execFn) {
		return fmt.Errorf("executor %s: function '%s' not found in exports", conf.GetName(), execFn)
	}
	return nil
}

View on GitHub (pinned to 93accf6570)

Solutions

  1. Check the error's per-scenario lines: they name the executor and the exact missing function
  2. Fix the exec value to match a key of the script's `export default { ... }` object exactly (case-sensitive)
  3. Export the intended function: `export default { myfn }` and use `exec: 'myfn'`
  4. If the function is only the default export, use exec: 'default' (the implicit default function name)

Example fix

// before
export default function () { /* ... */ }
export const options = { scenarios: { s1: { executor: 'per-vu-iterations', exec: 'login' } } };
// error: executor s1: function 'login' not found in exports

// after
export function login() { /* ... */ }
export default { login };
export const options = { scenarios: { s1: { executor: 'per-vu-iterations', exec: 'login' } } };
Defensive patterns

Strategy: validation

Validate before calling

// In-script guard: assert every scenario exec exists in exports before k6 validates
const exports = { login, checkout };
for (const [name, sc] of Object.entries(options.scenarios ?? {})) {
  if (!(sc.exec ?? 'default') in exports && sc.exec !== 'default') {
    throw new Error(`scenario ${name}: exec '${sc.exec}' not exported`);
  }
}
export default exports;

Type guard

function scenarioExecExists(scenario, exported) {
  const fn = scenario.exec ?? 'default';
  return fn === 'default' || Object.prototype.hasOwnProperty.call(exported, fn);
}

Prevention

When it happens

Trigger: Setting options.scenarios.<name>.exec (in the script, CLI --scenario-*/--exec flags, config file, or env K6_* scenario options) to a function that is not exported: `export default { orders: fn }` with `exec: 'order'` (typo), or `exec: 'default'` when only a default function export exists and the named export is missing; also when scenario options come from an external config file that diverges from the script.

Common situations: Renaming a function in the script but not in scenario options; copy-pasting options between scripts whose exports differ; driving scenarios purely via CLI/config (k6 run --config) where exec references drift from the archive's exports; the error message lists all invalid execs per scenario under a title in the aggregated validation error.

Related errors


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