grafana/k6 · error
the scenario name should contain only numbers, latin letters
Error message
the scenario name should contain only numbers, latin letters, underscores, and dashes
What it means
Emitted by BaseConfig.Validate (lib/executor/base_config.go:56-58) when a scenario name fails the regex ^[0-9a-zA-Z_-]+$ (scenarioNameWhitelist, line 22). Every scenario key under options.scenarios is a BaseConfig.Name (set from the JS object key per the json:"-" tag), and k6 enforces this charset so names stay safe for use in CLI flags, env vars, and Cloud/API identifiers. Names with spaces, dots, slashes, unicode, or empty names (the '+' requires at least one char) all fail.
Source
Thrown at lib/executor/base_config.go:57
// NewBaseConfig returns a default base config with the default values
func NewBaseConfig(name, configType string) BaseConfig {
return BaseConfig{
Name: name,
Type: configType,
GracefulStop: types.NewNullDuration(DefaultGracefulStopValue, false),
}
}
// Validate checks some basic things like present name, type, and a positive start time
func (bc BaseConfig) Validate() (result []error) {
// Some just-in-case checks, since those things are likely checked in other places or
// even assigned by us:
if bc.Name == "" {
result = append(result, errors.New("scenario name can't be empty"))
}
if !scenarioNameWhitelist.MatchString(bc.Name) {
result = append(result, errors.New(scenarioNameErr))
}
if bc.Exec.Valid && bc.Exec.String == "" {
result = append(result, errors.New("exec value cannot be empty"))
}
if bc.Type == "" {
result = append(result, errors.New("missing or empty type field"))
}
// The actually reasonable checks:
if bc.StartTime.Duration < 0 {
result = append(result, errors.New("the startTime can't be negative"))
}
if bc.GracefulStop.Duration < 0 {
result = append(result, errors.New("the gracefulStop timeout can't be negative"))
}
return result
}
// GetName returns the name of the scenario.View on GitHub (pinned to 93accf6570)
Solutions
- Rename the scenario key to use only letters, digits, underscore and dash, e.g. 'login_flow' instead of 'login flow'
- If hierarchy/naming clarity was the goal, use dashes as separators: 'smoke-eu' rather than 'smoke/eu' or 'smoke.eu'
- If generating configs programmatically, sanitize names before assignment: regexp replace of disallowed characters
Example fix
// before
export const options = {
scenarios: {
'quick smoke test': { executor: 'constant-vus', vus: 1, duration: '10s' },
},
};
// after
export const options = {
scenarios: {
quick_smoke_test: { executor: 'constant-vus', vus: 1, duration: '10s' },
},
}; Defensive patterns
Strategy: validation
Validate before calling
// JS: validate scenario keys before running
const nameOK = (n) => /^[0-9a-zA-Z_-]+$/.test(n);
const bad = Object.keys(options.scenarios || {}).filter((k) => !nameOK(k));
if (bad.length) throw new Error(`invalid scenario name(s): ${bad.join(', ')}`); Prevention
- Adopt a scenario naming convention of lowercase words joined by '-' or '_' from the start
- If scenario names come from templates or env vars, sanitize with n.replace(/[^0-9a-zA-Z_-]/g, '_') before use
- Lint exported options in CI (a tiny node script) so invalid names fail before any load is scheduled
When it happens
Trigger: Defining options.scenarios = { 'my scenario': {...} }, 'test.1', 'smoke/eu', 'café-1', or any key with characters outside [0-9a-zA-Z_-]. Also triggered programmatically when constructing executor configs (e.g. executor.NewBaseConfig or parsing scenario JSON) with such a name; Validate() collects this error among others.
Common situations: Users renaming scenarios for readability ('login flow'), copying scenario names containing dots from dashboards, or YAML/JS configs using descriptive keys with spaces. Common after migrating from old execution segments to the scenarios API where naming rules became strict.
Related errors
- scenario name can't be empty
- exec value cannot be empty
- missing or empty type field
- the startTime can't be negative
- the gracefulStop timeout can't be negative
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/60d8a4aea74c9225.
Report an issue: GitHub.