{"record":{"id":"60d8a4aea74c9225","repo":"grafana/k6","slug":"the-scenario-name-should-contain-only-numbers-lat","errorCode":null,"errorMessage":"the scenario name should contain only numbers, latin letters, underscores, and dashes","messagePattern":"the scenario name should contain only numbers, latin letters, underscores, and dashes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/executor/base_config.go","lineNumber":57,"sourceCode":"\n// NewBaseConfig returns a default base config with the default values\nfunc NewBaseConfig(name, configType string) BaseConfig {\n\treturn BaseConfig{\n\t\tName:         name,\n\t\tType:         configType,\n\t\tGracefulStop: types.NewNullDuration(DefaultGracefulStopValue, false),\n\t}\n}\n\n// Validate checks some basic things like present name, type, and a positive start time\nfunc (bc BaseConfig) Validate() (result []error) {\n\t// Some just-in-case checks, since those things are likely checked in other places or\n\t// even assigned by us:\n\tif bc.Name == \"\" {\n\t\tresult = append(result, errors.New(\"scenario name can't be empty\"))\n\t}\n\tif !scenarioNameWhitelist.MatchString(bc.Name) {\n\t\tresult = append(result, errors.New(scenarioNameErr))\n\t}\n\tif bc.Exec.Valid && bc.Exec.String == \"\" {\n\t\tresult = append(result, errors.New(\"exec value cannot be empty\"))\n\t}\n\tif bc.Type == \"\" {\n\t\tresult = append(result, errors.New(\"missing or empty type field\"))\n\t}\n\t// The actually reasonable checks:\n\tif bc.StartTime.Duration < 0 {\n\t\tresult = append(result, errors.New(\"the startTime can't be negative\"))\n\t}\n\tif bc.GracefulStop.Duration < 0 {\n\t\tresult = append(result, errors.New(\"the gracefulStop timeout can't be negative\"))\n\t}\n\treturn result\n}\n\n// GetName returns the name of the scenario.","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/lib/executor/base_config.go#L39-L75","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nexport const options = {\n  scenarios: {\n    'quick smoke test': { executor: 'constant-vus', vus: 1, duration: '10s' },\n  },\n};\n\n// after\nexport const options = {\n  scenarios: {\n    quick_smoke_test: { executor: 'constant-vus', vus: 1, duration: '10s' },\n  },\n};","handlingStrategy":"validation","validationCode":"// JS: validate scenario keys before running\nconst nameOK = (n) => /^[0-9a-zA-Z_-]+$/.test(n);\nconst bad = Object.keys(options.scenarios || {}).filter((k) => !nameOK(k));\nif (bad.length) throw new Error(`invalid scenario name(s): ${bad.join(', ')}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["config","scenarios","validation","k6"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}