{"record":{"id":"7b363a8a945596c1","repo":"grafana/k6","slug":"exec-value-cannot-be-empty","errorCode":null,"errorMessage":"exec value cannot be empty","messagePattern":"exec value cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/executor/base_config.go","lineNumber":60,"sourceCode":"\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.\nfunc (bc BaseConfig) GetName() string {\n\treturn bc.Name\n}","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/lib/executor/base_config.go#L42-L78","documentation":"Emitted by BaseConfig.Validate (lib/executor/base_config.go:59-61) when the scenario's exec field is present and Valid but set to an empty string. exec is a null.String: it is only meant to hold the name of an exported JS function that this scenario should run instead of default. An explicitly empty string is treated as a configuration mistake — omitting the field entirely is the correct way to use the default function.","triggerScenarios":"Setting scenarios: { smoke: { executor: 'per-vu-iterations', exec: '' } } in exported options, or unmarshaling scenario JSON that contains an \"exec\": \"\" member. Validate() fires during config validation before the test starts.","commonSituations":"Templated scripts that interpolate a function name from a variable which is empty (e.g. __ENV.SCENARIO_FUNC unset), or a leftover empty exec after commenting out the intended function name.","solutions":["Remove the exec property from the scenario so it falls back to the default exported function","Or set it to an actual exported function name defined in the script, e.g. exec: 'login'","If the value comes from an env var, default it or conditionally include the property only when non-empty"],"exampleFix":"// before\nexport const options = {\n  scenarios: {\n    smoke: { executor: 'shared-iterations', exec: '' },\n  },\n};\n\n// after\nexport const options = {\n  scenarios: {\n    smoke: { executor: 'shared-iterations' }, // uses default export\n  },\n};","handlingStrategy":"validation","validationCode":"// Only include exec when it names a real exported function\nconst fn = __ENV.SCENARIO_FUNC;\nexport const options = {\n  scenarios: {\n    smoke: {\n      executor: 'shared-iterations',\n      ...(fn ? { exec: fn } : {}),\n    },\n  },\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never write exec: '' — omit the key to use the default export","When exec is env-driven, default it and assert the function exists: if (typeof globalThis[fn] !== 'function') throw new Error(...)","Remember k6 only accepts exported top-level functions as exec targets"],"tags":["config","scenarios","exec","validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}